Url

Overview

Represents a Uniform Resource Locator, a pointer to a resource on the World Wide Web.

Use case

You can use URL class to specify some resource and get access to individual part of an url, for example:

var Url := new Sugar.Url("http://example.com/index.html");
writeLn(Url.Host);
writeLn(Url.Path);
writeLn(Url.Scheme);

Output:

example.com
/index.html
http

Location

  • Reference: Sugar
  • Namespace: Sugar

 

constructor

Creates a new instance of the class with specified parameter.

 

constructor(UriString: String)

 

Url(String UriString)

 

init(_ UriString: String)

 

Url(String UriString)

Parameters:

  • UriString: String representation of the url.

Fragment

Gets the escaped url fragment.

 

property Fragment: String read;

 

String Fragment { get; }

 

var Fragment: String { get{} }

 

String Fragment { __get; }

GetParentUrl  mapped

 

method GetParentUrl: Url

 

Url GetParentUrl()

 

func GetParentUrl() -> Url

 

Url GetParentUrl()

GetSubUrl  mapped

 

method GetSubUrl(aName: String): Url

 

Url GetSubUrl(String aName)

 

func GetSubUrl(_ aName: String) -> Url

 

Url GetSubUrl(String aName)

Parameters:

  • aName:

Host

Gets the host component.

 

property Host: String read;

 

String Host { get; }

 

var Host: String { get{} }

 

String Host { __get; }

Path

Gets the absolute path of the url.

 

property Path: String read;

 

String Path { get; }

 

var Path: String { get{} }

 

String Path { __get; }

Port

Gets the port numbe or -1 in case it wasn't specified.

 

property Port: Int32 read;

 

Int32 Port { get; }

 

var Port: Int32 { get{} }

 

Int32 Port { __get; }

QueryString

Gets any query information.

 

property QueryString: String read;

 

String QueryString { get; }

 

var QueryString: String { get{} }

 

String QueryString { __get; }

Scheme

Gets the scheme name.

 

property Scheme: String read;

 

String Scheme { get; }

 

var Scheme: String { get{} }

 

String Scheme { __get; }

UrlEncodeString

 

class method UrlEncodeString(aString: String): String

 

static String UrlEncodeString(String aString)

 

static func UrlEncodeString(_ aString: String) -> String

 

static String UrlEncodeString(String aString)

Parameters:

  • aString:

UserInfo

Gets the user name, password, or other user-specific information.

 

property UserInfo: String read;

 

String UserInfo { get; }

 

var UserInfo: String { get{} }

 

String UserInfo { __get; }

 

Fragment

Gets the escaped url fragment.

 

property Fragment: String read;

 

String Fragment { get; }

 

var Fragment: String { get{} }

 

String Fragment { __get; }

Host

Gets the host component.

 

property Host: String read;

 

String Host { get; }

 

var Host: String { get{} }

 

String Host { __get; }

Path

Gets the absolute path of the url.

 

property Path: String read;

 

String Path { get; }

 

var Path: String { get{} }

 

String Path { __get; }

Port

Gets the port numbe or -1 in case it wasn't specified.

 

property Port: Int32 read;

 

Int32 Port { get; }

 

var Port: Int32 { get{} }

 

Int32 Port { __get; }

QueryString

Gets any query information.

 

property QueryString: String read;

 

String QueryString { get; }

 

var QueryString: String { get{} }

 

String QueryString { __get; }

Scheme

Gets the scheme name.

 

property Scheme: String read;

 

String Scheme { get; }

 

var Scheme: String { get{} }

 

String Scheme { __get; }

UserInfo

Gets the user name, password, or other user-specific information.

 

property UserInfo: String read;

 

String UserInfo { get; }

 

var UserInfo: String { get{} }

 

String UserInfo { __get; }

 

UrlEncodeString

 

class method UrlEncodeString(aString: String): String

 

static String UrlEncodeString(String aString)

 

static func UrlEncodeString(_ aString: String) -> String

 

static String UrlEncodeString(String aString)

Parameters:

  • aString:

 

constructor

Creates a new instance of the class with specified parameter.

 

constructor(UriString: String)

 

Url(String UriString)

 

init(_ UriString: String)

 

Url(String UriString)

Parameters:

  • UriString: String representation of the url.

GetParentUrl  mapped

 

method GetParentUrl: Url

 

Url GetParentUrl()

 

func GetParentUrl() -> Url

 

Url GetParentUrl()

GetSubUrl  mapped

 

method GetSubUrl(aName: String): Url

 

Url GetSubUrl(String aName)

 

func GetSubUrl(_ aName: String) -> Url

 

Url GetSubUrl(String aName)

Parameters:

  • aName: