Mountain/IPC/UriComponents/Normalize.rs
1#![allow(non_snake_case)]
2
3//! Normalise an `extensionLocation` (or any similar) field that arrives
4//! as either a URL string, a pre-built `UriComponents` object (possibly
5//! already tagged), or is missing / null. The output is always a
6//! tagged object with the five URI fields.
7
8use serde_json::Value;
9
10use crate::IPC::UriComponents::{FromFilePath, FromUrl, StampMidUri};
11
12pub fn Fn(Raw:Option<&Value>) -> Value {
13 match Raw {
14 Some(Value::Object(Map)) if Map.contains_key("scheme") => StampMidUri::Fn(Value::Object(Map.clone())),
15 Some(Value::String(Url)) => FromUrl::Fn(Url),
16 _ => FromFilePath::Fn("/extensions/unknown"),
17 }
18}