Skip to main content

URL parsing

Parse urls using the http module, works with inflight closures.

main.w
bring http;
bring cloud;

new cloud.Function(inflight () => {
let parts = http.parseUrl("postgres://user:pass@host.com:5432/path?k=v#f");

log(parts.hostname);
log(parts.host);
log(parts.hash);
log(parts.origin);
log(parts.username);
log(parts.password);
log(parts.pathname);
log(parts.port);
log(parts.protocol);
log(parts.search);

});
Wing console output
# Run locally with wing console and invoke the cloud function
host.com
host.com:5432
#f
null
user
pass
/path
5432
postgres:
?k=v