urlUtils

ESM: import * as urlUtils from "@arcgis/core/core/urlUtils.js";
CDN: const urlUtils = await $arcgis.import("@arcgis/core/core/urlUtils.js");
Object: @arcgis/core/core/urlUtils
Since: ArcGIS Maps SDK for JavaScript 4.0

Utility methods for working with URLs.

Method Overview

Name Return Type Summary Object

Adds the given proxy rule to the proxy rules list: esriConfig.request.proxyRules.

urlUtils

Converts a base64 encoded data url to an ArrayBuffer.

urlUtils

Converts a base64 encoded data url to a Blob.

urlUtils

Trigger a browser file download from a data url encoded as binary data.

urlUtils

Trigger a browser file download from a base64 encoded data url.

urlUtils

Returns the proxy rule that matches the given URL.

urlUtils

Tests whether a url uses the data protocol.

urlUtils

Tests whether a url uses the https protocol.

urlUtils

Converts the URL arguments to an object representation.

urlUtils

Method Details

addProxyRule

Method
addProxyRule(rule){Number}

Adds the given proxy rule to the proxy rules list: esriConfig.request.proxyRules.

Parameters
Specification
rule Object

An object specifying a URL that should use the proxy. See the object specification table below for the required properties of this object.

Specification
proxyUrl String

The URL of the proxy.

urlPrefix String

The URL prefix of the resources that should be accessed through the given proxy.

Returns
Type Description
Number The index of the proxy rule in the esriConfig.request.proxyRules array.

dataToArrayBuffer

Method
dataToArrayBuffer(dataUrl){ArrayBuffer |null |undefined}
Since: ArcGIS Maps SDK for JavaScript 4.33 urlUtils since 4.0, dataToArrayBuffer added at 4.33.

Converts a base64 encoded data url to an ArrayBuffer.

Parameter
dataUrl String

the data url

Returns
Type Description
ArrayBuffer | null | undefined the array buffer with the data url encoded as binary data.

dataToBlob

Method
dataToBlob(dataUrl){Blob |null |undefined}
Since: ArcGIS Maps SDK for JavaScript 4.33 urlUtils since 4.0, dataToBlob added at 4.33.

Converts a base64 encoded data url to a Blob.

Parameter
dataUrl String

the data url.

Returns
Type Description
Blob | null | undefined the blob with the data url encoded as binary data.

downloadBlobAsFile

Method
downloadBlobAsFile(blob, filename)
Since: ArcGIS Maps SDK for JavaScript 4.33 urlUtils since 4.0, downloadBlobAsFile added at 4.33.

Trigger a browser file download from a data url encoded as binary data.

Parameters
blob Blob

The data url to download (as binary data.

filename String

the filename.

See also

downloadDataAsFile

Method
downloadDataAsFile(dataUrl, filename)
Since: ArcGIS Maps SDK for JavaScript 4.33 urlUtils since 4.0, downloadDataAsFile added at 4.33.

Trigger a browser file download from a base64 encoded data url.

Parameters
dataUrl String

the data url.

filename String

the filename.

getProxyRule

Method
getProxyRule(url){Object |null |undefined}

Returns the proxy rule that matches the given URL.

Parameter
url String

The URL of the resources accessed via proxy.

Returns
Type Description
Object | null | undefined The proxy rule object as defined in esriConfig.request.proxyRules.

isDataProtocol

Method
isDataProtocol(url){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.32 urlUtils since 4.0, isDataProtocol added at 4.32.

Tests whether a url uses the data protocol.

This will return true if the url starts with data:.

Parameter
url String

The url to test.

Returns
Type Description
Boolean Returns true if the url uses the data protocol, false otherwise.

isHTTPSProtocol

Method
isHTTPSProtocol(url){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.32 urlUtils since 4.0, isHTTPSProtocol added at 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.

Parameter
url String

The url to test.

Returns
Type Description
Boolean Returns true if the url uses the https protocol, false otherwise.

urlToObject

Method
urlToObject(url){Object |null |undefined}

Converts the URL arguments to an object representation.

Parameter

The input URL.

Returns
Type Description
Object | null | undefined 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"} }

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