Published
Edited
Aug 23, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
{
let uri = uris.parseUri("hello://foo.bar/a/b/?a=b&c=d#foobar?x=y#toto");
uri = uris.resolveUrl(uri, "./index.md?x=y");
return uris.serializeUri(uri);
}
Insert cell
Insert cell
uris.parseUri("hello://foo.bar/a/b/?a=b&c=d#foobar?x=y#toto")
Insert cell
Insert cell
uris.resolveUrl("http://foo.bar/a/b/index.md", "./")
Insert cell
uris.resolveUrl("http://foo.bar/a/b/", "../doc/", "./my/path.txt")
Insert cell
uris.resolveUrl("http://foo.bar/a/b/index.md", "../hello/../world/path.txt")
Insert cell
uris.resolveUrl("http://foo.bar/a/b/index.md", "../hello/", "../world/path.txt")
Insert cell
Insert cell
uris.concatPath("http://foo.bar/a/b/", "/my/path.txt")
Insert cell
uris.concatPath("http://foo.bar/a/b/", "ftp://foo.bar/my/path.txt")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
// Rewriting rules:
const transform = uris.newPathMapping([
{ source: "./sources/", target: "/" },
{ source: "file:///tmp/data/", target: "/toto/" },
{ source: "http://www.foo.bar/tech/", target: "/docs/" },
{ source: "http://www.foo.bar/assets/img/", target: "/images/" }
]);

const result = [
"./sources/index.md",
"http://www.foo.bar/tech/readme.md",
"http://www.foo.bar/assets/img/MyImage.jpg",
"file:///tmp/data/products/prices.md"
].map((uri) => [uri, transform(uri)]);
return Object.fromEntries(result);
}
Insert cell
Insert cell
uris.parseUri("http://foo.bar/a/b/?a=b&c=d#foobar?x=y#baz")
Insert cell
Insert cell
uris.serializeUri({
schema: "https",
domain: "abc.cde",
path: "a/b/c",
query: { hello: "Wonderful World" },
fragment: "abc"
})
Insert cell
Insert cell
uris.concatPath("http://foo.bar/a/b/index.md", "../hello/../world/path.txt")
Insert cell
uris.resolveUrl(
uris.concatPath("http://foo.bar/a/b/index.md", "../hello/../world/path.txt")
)
Insert cell
Insert cell
uris = import("@statewalker/uris@0.2")
Insert cell
import { toc } from "@nebrius/indented-toc"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more