import { urlToObject, addProxy, addProxyRule, getProxyRule, isDataProtocol } from "@arcgis/core/core/urlUtils.js";const { urlToObject, addProxy, addProxyRule, getProxyRule, isDataProtocol } = await $arcgis.import("@arcgis/core/core/urlUtils.js");- Since
- ArcGIS Maps SDK for JavaScript 4.0
Utility methods for working with URLs.
Functions
urlToObject
Converts the URL arguments to an object representation.
- Signature
-
urlToObject (url: string | null | undefined): any | null
- Returns
- any | null
Returns an object representing the URL, its parameters, and parameter values. The specification of the object is the following:
Property Type Description path String The path of the given URL. query Object An object whose properties and values are the parameters and parameter values of the given URL.
- Example
- let myObject = urlUtils.urlToObject("http://www.myworld.com?state_name=Ohio&city_name=Akron");// The value of my Object is...// { path: "http://www.myworld.com", query: {state_name: "Ohio", city_name: "Akron"} }
addProxy
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Adds a proxy to the given url based on the proxy rules defined in esriConfig.request.proxyRules.
If no proxy rule matches, and force is true, the global proxy defined in esriConfig.request.proxyUrl is used.
- Signature
-
addProxy (url: string, force?: boolean): string
addProxyRule
Adds the given proxy rule to the proxy rules list: esriConfig.request.proxyRules.
- See also
- Signature
-
addProxyRule (rule: ProxyRule): number
getProxyRule
Returns the proxy rule that matches the given URL.
- See also
- Signature
-
getProxyRule (url: string): ProxyRule | null | undefined
isDataProtocol
- Since
- ArcGIS Maps SDK for JavaScript 4.32
Tests whether a URL uses the data protocol.
This will return true if the URL starts with data:.
- Signature
-
isDataProtocol (url: string | null | undefined): boolean
dataToArrayBuffer
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Converts a base64 encoded data url to an ArrayBuffer.
- Signature
-
dataToArrayBuffer (dataUrl: string): ArrayBuffer | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| dataUrl | The data URL. | |
- Returns
- ArrayBuffer | null | undefined
The array buffer with the data URL encoded as binary data.
dataToBlob
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Converts a base64 encoded data url to a Blob.
- Signature
-
dataToBlob (dataUrl: string): Blob | null | undefined
downloadDataAsFile
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Trigger a browser file download from a base64 encoded data URL.
- Signature
-
downloadDataAsFile (dataUrl: string, filename: string): void
downloadBlobAsFile
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Trigger a browser file download from a data URL encoded as binary data.
- See also
- Signature
-
downloadBlobAsFile (blob: Blob, filename: string): void
isHTTPSProtocol
- Since
- ArcGIS Maps SDK for JavaScript 4.32
Tests whether a URL uses the https protocol.
This will return true if the URL starts with the https protocol, or if
the URL is protocol relative and the application is running on https.
- Signature
-
isHTTPSProtocol (url: string | null | undefined): boolean
Type definitions
ProxyRule
A proxy rule that matches a URL to a proxy URL.
- See also
urlPrefix
- Type
- string
The URL prefix of the resources that should be accessed through the given proxy.