I wonder if there is a simple way to extract Authority from an URL string.
What is Authority of URL: https://en.wikipedia.org/wiki/URL#Syntax



https://dlang.org/phobos/std_path.html
I was able to gather the filename of URL via std.path package function: baseName.

import std.stdio, std.path;
void main()
{
string url = "https://github.com/BoQsc/notes/archive/master.zip";;

// Output: url filename: master.zip
writeln("url filename: ", url.baseName);

// Output: url path: https://github.com/BoQsc/notes/archive
writeln("url path: ", url.dirName);


}



However it seems that std.path lacks ability to extract Authority part that URL contains.

https://dlang.org/phobos/std_path.html#rootName
I tried std.path.rootName, but it didn't return Authority part of URL.

import std.stdio, std.path;
void main()
{
string url = "https://github.com/BoQsc/notes/archive/master.zip";;

// Output: url path:
writeln("url path: ", url.rootName);
}


I'm questioning, if D lang will ever include simple URL parsing into their std Phobos library?

Reply via email to