urld 3.0.1

A URL parsing library


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

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.

Recent Breaking Changes

  • v3.0:
    • urld does no automatic URL decoding
    • urld only automatically encodes non-ASCII characters
    • URL(string) constructor parses a URL rather than assigning the scheme only

Installation

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

Usage

Parse a URL:

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

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/[email protected]"));

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:[email protected]: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/");
Authors:
  • dhasenan
Dependencies:
none
Versions:
3.0.1 2024-Jul-23
3.0.0 2024-Jul-23
2.1.1 2018-Jul-22
2.1.0 2017-Jan-14
2.0.2 2017-Jan-12
Show all 24 versions
Download Stats:
  • 268 downloads today

  • 800 downloads this week

  • 2695 downloads this month

  • 296094 downloads total

Score:
4.0
Short URL:
urld.dub.pm