MCPcopy
hub / github.com/foambubble/foam / parse

Method parse

packages/foam-core/src/model/uri.ts:58–78  ·  view source on GitHub ↗

* Parses a string value into a URI object. * @param value the string value of the URI * @param defaultScheme the default scheme to use if none is provided in the value. * - if a `string`, it will be used as the default scheme * - if a `URI`, its scheme will be used as the default scheme

(value: string, defaultScheme: URI | string | null)

Source from the content-addressed store, hash-verified

56 * @throws if no scheme is provided in value and no default scheme is given
57 */
58 static parse(value: string, defaultScheme: URI | string | null): URI {
59 const match = _regexp.exec(value);
60 if (!match) {
61 return new URI();
62 }
63 defaultScheme =
64 defaultScheme instanceof URI
65 ? defaultScheme.scheme
66 : (defaultScheme as string | null);
67 const scheme = match[2] || defaultScheme;
68 if (isNone(scheme)) {
69 throw new Error(`Invalid URI: The URI scheme is missing: ${value}`);
70 }
71 return new URI({
72 scheme,
73 authority: percentDecode(match[4] ?? _empty),
74 path: pathUtils.fromFsPath(percentDecode(match[5] ?? _empty))[0],
75 query: percentDecode(match[7] ?? _empty),
76 fragment: percentDecode(match[9] ?? _empty),
77 });
78 }
79
80 /**
81 * @deprecated Will not work with web extension. Use only for testing.

Callers 15

callToolJsonFunction · 0.45
parseUriInputFunction · 0.45
server.test.tsFile · 0.45
resources.test.tsFile · 0.45
esbuild.jsFile · 0.45
getFragmentFromSettingsFunction · 0.45
makeWorkspaceFunction · 0.45
createFileFunction · 0.45
parseFunction · 0.45
fromFunction · 0.45
joinPathFunction · 0.45
entriesMethod · 0.45

Calls 2

isNoneFunction · 0.90
percentDecodeFunction · 0.85

Tested by 7

makeWorkspaceFunction · 0.36
callToolFunction · 0.36
parseJsonFunction · 0.36
createNoteFromMarkdownFunction · 0.36
createNoteFromMarkdownFunction · 0.36
parseNoteFunction · 0.36
buildWorkspaceFunction · 0.36