MCPcopy Create free account
hub / github.com/arfct/itty-bitty / pathToMetadata

Function pathToMetadata

docs/bitty.js:547–559  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

545}
546
547function pathToMetadata(path) {
548 let components = path.substring(1).split("/");
549 let info = {title: decodePrettyComponent(components.shift())}
550 for (let i = 0; i < components.length; i+=2) {
551 let key = components[i];
552 let value = components[i+1];
553 if (!value) continue;
554 if (key == "d") { value = decodePrettyComponent(value); }
555 else if (value.includes("%")) { value = decodeURIComponent(value); }
556 if (key.length && value.length) info[key] = value;
557 }
558 return info;
559}
560
561function metadataToPath(data) {
562 if (!data || !data.title) return "/";

Callers

nothing calls this directly

Calls 1

decodePrettyComponentFunction · 0.70

Tested by

no test coverage detected