Description

A URL parsing library

Package Information

Version 2.1.0 (2017-Jan-14)
Repository https://github.com/dhasenan/urld
License MIT
Copyright Copyright © 2015, dhasenan
Authors dhasenan
Registered by Christopher Wright
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

urld

URL handling for D

Motivation

D's standard library has nothing for working with URLs.

Vibe.d can work with URLs. However, Vibe is big. Also, we want to work easily with query strings, which vibe.d doesn't allow.

Status

There are some convenience accessors to add.

No backwards-incompatible changes are planned.

Installation

Add "urld": "~>2.0.1" to your dub.json.

Usage

Parse a URL:

auto url = "ircs://irc.freenode.com/#d".parseURL;

Construct one from scratch, laboriously:

URL url;
with (url) {
	scheme = "soap.beep";
	host = "beep.example.net";
	port = 1772;
	path = "/serverinfo/info";
  queryParams.add("token", "my-api-token");
}
curl.get(url);

Unicode domain names:

auto url = "http://☃.com/".parseURL;
writeln(url.toString);               // http://xn--n3h.com/
writeln(url.toHumanReadableString);  // http://☃.com/

Implicit conversion to strings for use with other libraries that expect URLs as strings:

import std.net.curl;
auto couchdbURL = "http://couch.local:8815".parseURL;
writeln(get(couchdbURL ~ "users/bob.dobbs@subgenius.org"));

Autodetect ports:

assert(parseURL("http://example.org").port == 80);
assert(parseURL("http://example.org:5326").port == 5326);

URLs of maximum complexity:

auto url = parseURL("redis://admin:password@redisbox.local:2201/path?query=value#fragment");
assert(url.scheme == "redis");
assert(url.user == "admin");
assert(url.pass == "password");
// etc

URLs of minimum complexity:

assert(parseURL("example.org").toString == "http://example.org/");

Canonicalization:

assert(parseURL("http://example.org:80").toString == "http://example.org/");

Available versions

2.1.0 2.0.2 2.0.1 2.0.0 1.3.1 1.3.0 1.2.0 1.1.0 1.0.0 0.5.2 0.5.1 0.5.0 0.4.0 0.3.1 0.3.0 0.2.2 0.2.1 0.2.0 0.1.0 0.0.1 ~master