Node.js like URL constructor for Delphi.
Add it to your uses
uses UrlParser;
Then you can simply call it.
var
url: String;
begin
url := TUrlParser.Create
.Protocol(stHttps)
.Username('myuser')
.Password('mypass')
.BaseUrl('thisisatest.com')
.Port(3574)
.AddResource('tests')
.AddResource('subTests')
.AddParameter('thisisa', 'test')
.AddParameter('useiton', 'delphi')
.ToString);
end;
The sample above would return the url below as a string
https://myuser:[email protected]:3574/tests/subTests?thisisa=test&useiton=delphi
New parsing method is now availabe.
var
LUrlObject: IUrlParser;
begin
LUrlObject := TUrlParser.Create.Parse('https://www.thisisatest.com/tests/subTests?thisisa=test&useiton=delphi');
end;
The sample above would return a IUrlParser
interface that would contain following attributes: Protocol
, BaseUrl
, Resources
and Parameters
of the parsed url.
Simply drop the UrlParser.pas in your project's folder and add it to the project.
Installation using Boss
boss install github.com/nickolasdeluca/UrlParser