UrlInfo QML Type

A convenience component that allows a user to deconstruct a link such as a web address. More...

Import Statement: import ArcGIS.AppFramework 1.0

Properties

Methods

Detailed Description

The UrlInfo component provides a number of properties and methods that help construct and deconstruct urls. For more information on the URI schemes - https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

For example,

Button {
    text: qsTr("UrlInfo Tests")
    onClicked: {
        // Using UrlInfo to parse and extract portions of a URL.
        let url = "https://www.arcgis.com/sharing/rest/info?f=pjson&token=ABC";
        let urlInfo = AppFramework.urlInfo(url);
        console.log(urlInfo.url); // qml: https://www.arcgis.com/sharing/rest/info?f=pjson&token=ABC
        console.log(urlInfo.scheme); // qml: https
        console.log(urlInfo.host); // qml: www.arcgis.com
        console.log(urlInfo.path); // qml: /sharing/rest/info
        console.log(urlInfo.query); // qml: f=pjson&tokenABC
        console.log(JSON.stringify(urlInfo.queryParameters)); // qml: { "f": "pjson", "token": "ABC" }

        // Using UrlInfo to change query parameters.
        let urlBuilder = AppFramework.urlInfo(url);
        console.log(urlBuilder.url); // qml: https://www.arcgis.com/sharing/rest/info?f=pjson&token=ABC
        let p = urlInfo.queryParameters;
        p.token = "XYZ";
        urlBuilder.queryParameters = p;
        console.log(urlBuilder.url); // qml: https://www.arcgis.com/sharing/rest/info?f=pjson&token=XYZ

        // Using UrlInfo to suppress the query parameters.
        let cleanUrlInfo = AppFramework.urlInfo(url);
        cleanUrlInfo.query = "";
        console.log(cleanUrlInfo.url); // qml: https://www.arcgis.com/sharing/rest/info

        // Using UrlInfo to extract the raw host information.
        let rootUrlInfo = AppFramework.urlInfo(url);
        rootUrlInfo.query = "";
        rootUrlInfo.path = "";
        console.log(rootUrlInfo.url); // qml: https://www.arcgis.com
    }
}

Property Documentation

authority : string

This property is comprised of the user information (optional), host and port if available. For example, username:password@example.com:123


[read-only] fileName : string

Name of the file that is opened. For example, myPage.html.


fragment : string

Provides direction to a secondary resource, such as a section heading in an article identified by the remainder of the URI. For example, "myPage.html#section3". The #section3 denotes a location within the page.


[read-only] hasFragment : bool

Boolean value. Returns true if the url passed in has a fragment.


[read-only] hasQuery : bool

Boolean value. Returns true if the url has a query as part of the structure.


host : string

The host consists of either a registered name (including but not limited to a hostname), or an IP address. IPv4 addresses must be in dot-decimal notation, and IPv6 addresses must be enclosed in brackets ([ ]).


[read-only] isEmpty : bool

Boolean value. Returns true if the url provided is empty.


[read-only] isLocalFile : bool

Boolean value. Returns true if the url is referring to a local file. For example, "file:///c:/temp/Bruce.txt"


[read-only] isValid : bool

Boolean value. Returns true if the url has a valid address/location and is well formed.


localFile : string

Returns the string of the objects file path if it is a local file.

For example,

var pictureUrlInfo = AppFramework.urlInfo(pictureUrl); var picturePath = pictureUrlInfo.localFile;

returns an address like "C:/temp/Bruce.jpg"


password : string

Returns a string value of the optional property of a url.


path : string

Returns the string value that is directly after the authority section of a url. For example, "/pathname/Bruce.html".


port : int

An optional number in the url that is separated from the hostname by a colon. For example, example.com:1234.


query : string

An optional parameter of a url. This can be used to define a question about the data/content that is being accessed by the url.


queryPairDelimiter : string

Returns the character used to delimit between keys-value pairs when reconstructing the query string.


queryParameters : object

JSON object. Set of key-pair values that define a query for a specific url. For example,

urlInfo.queryParameters = {"name": "Ashton", "sister":"Indie"};

queryValueDelimiter : string

Returns the character used to delimit between keys and values when reconstructing the query string.


scheme : string

String value. Returns the standard protocol that is used for the url provided. For example, "http" or "file" or "survey123".


[read-only] topLevelDomain : string

String value. Returns the segment that describes the domain type of the url. For example, ".com".


url : url

Stores the full url of the string passed in.


userInfo : string

String value. Returns the optional parameters of username and password. For example, username:password.


userName : string

String value. Optional property of authentication within a url.


Method Documentation

bool fromPercentEncoding(string string)

The string parameter


bool fromString(string string)

This method initialises the dissemenation of the url provided.

Setting a string can be static or dynamically done, depending on the requirements of the app. For example, urlInfo.fromString("http://appstudioRocks.com")

The string parameter

String value. "www.example.com:1234" or "file:///c:/temp/Bruce.txt"


bool fromUserInput(string userInput)

This method initialises the dissemenation of the url provided.

Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.

The userInput parameter

String value. For example, "http://www.esri.com"


bool fromUserInput(string userInput, string workingDirectory)

Returns a valid url from a user supplied userInput string if one can be deducted.

Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.

The userInput parameter

String value. For example, "http://www.arcgis.com"

The workingDirectory parameter

This property is particularly useful when handling command line arguments. If workingDirectory is empty, no handling of relative paths will be done, so this method will behave like its one argument overload.


bool isParentOf(url url)

Returns true if the url property is a parent of the childUrl parameter.

childUrl is a child of this URL if the two URLs share the same scheme and authority and this URL's path is a parent of the path of childUrl.

For example,

Item {
        UrlInfo {
                id: urlInfo
                url: "http://arcgis-server1022-2082234468.us-east-1.elb.amazonaws.com/arcgis/rest/services/MobileApps/Water_Leaks_VGI/FeatureServer"
        }

        Component.onCompleted {
                var testParent = urlInfo.isParentOf("http://arcgis-server1022-2082234468.us-east-1.elb.amazonaws.com/arcgis/rest/services/MobileApps/Water_Leaks_VGI/FeatureServer/0/query")
                console.log(testParent) // would return true.
        }
}

The url parameter

For example, "http://www.arcgis.com"


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.