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
- authority : string
- fileName : string
- fragment : string
- hasFragment : bool
- hasQuery : bool
- host : string
- isEmpty : bool
- isLocalFile : bool
- isValid : bool
- localFile : string
- password : string
- path : string
- port : int
- query : string
- queryPairDelimiter : string
- queryParameters : object
- queryValueDelimiter : string
- scheme : string
- topLevelDomain : string
- url : url
- userInfo : string
- userName : string
Methods
- bool fromPercentEncoding(string string)
- bool fromString(string string)
- bool fromUserInput(string userInput)
- bool fromUserInput(string userInput, string workingDirectory)
- bool isParentOf(url url)
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
This property is comprised of the user information (optional), host and port if available. For example, username:password@example.com:123
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.
Boolean value. Returns true if the url has a query as part of the structure.
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 ([ ]).
Boolean value. Returns true if the url is referring to a local file. For example, "file:///c:/temp/Bruce.txt"
Boolean value. Returns true if the url has a valid address/location and is well formed.
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"
Returns the string value that is directly after the authority section of a url. For example, "/pathname/Bruce.html".
An optional number in the url that is separated from the hostname by a colon. For example, example.com:1234.
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.
Returns the character used to delimit between keys-value pairs when reconstructing the query string.
JSON object. Set of key-pair values that define a query for a specific url. For example,
urlInfo.queryParameters = {"name": "Ashton", "sister":"Indie"};
Returns the character used to delimit between keys and values when reconstructing the query string.
String value. Returns the standard protocol that is used for the url provided. For example, "http" or "file" or "survey123".
String value. Returns the segment that describes the domain type of the url. For example, ".com".
String value. Returns the optional parameters of username and password. For example, username:password.
Method Documentation
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"
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"
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.
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"