URL.resolve

Convert a relative URL to an absolute URL.

This is designed so that you can scrape a webpage and quickly convert links within the page to URLs you can actually work with, but you're clever; I'm sure you'll find more uses for it.

It's biased toward HTTP family URLs; as one quirk, "//" is interpreted as "same scheme, different everything else", which might not be desirable for all schemes.

This only handles URLs, not URIs; if you pass in 'mailto:bob.dobbs@subgenius.org', for instance, this will give you our best attempt to parse it as a URL.

struct URL
resolve
(
string other
)

Examples

auto base = "https://example.org/passworddb?secure=false".parseURL;

// Download https://example.org/passworddb/by-username/dhasenan
download(base.resolve("by-username/dhasenan"));

// Download https://example.org/static/style.css
download(base.resolve("/static/style.css"));

// Download https://cdn.example.net/jquery.js
download(base.resolve("https://cdn.example.net/jquery.js"));

Meta