import { urlToObject, addProxy, addProxyRule, getProxyRule, isDataProtocol } from "@arcgis/core/core/urlUtils.js";
Since
ArcGIS Maps SDK for JavaScript 4.0

Utility methods for working with URLs.

See also

Functions

urlToObject

Function

Converts the URL arguments to an object representation.

Signature
urlToObject (url: string | null | undefined): any | null

Parameters

ParameterTypeDescriptionRequired
url

The input URL.

Returns
any | null

Returns an object representing the URL, its parameters, and parameter values. The specification of the object is the following:

PropertyTypeDescription
pathStringThe path of the given URL.
queryObjectAn 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

Function
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

Parameters

ParameterTypeDescriptionRequired
url

The URL to which the proxy will be added.

force

= false - If true, the global proxy defined in esriConfig.request.proxyUrl is used when no proxy rule matches.

Returns
string

The URL with the proxy added if applicable.

addProxyRule

Function

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

See also
Signature
addProxyRule (rule: ProxyRule): number

Parameters

ParameterTypeDescriptionRequired
rule

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

Returns
number

The index of the proxy rule in the esriConfig.request.proxyRules array.

getProxyRule

Function

Returns the proxy rule that matches the given URL.

See also
Signature
getProxyRule (url: string): ProxyRule | null | undefined

Parameters

ParameterTypeDescriptionRequired
url

The URL of the resources accessed via proxy.

Returns
ProxyRule | null | undefined

The proxy rule object as defined in esriConfig.request.proxyRules.

isDataProtocol

Function
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

Parameters

ParameterTypeDescriptionRequired
url

The URL to test.

Returns
boolean

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

dataToArrayBuffer

Function
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

ParameterTypeDescriptionRequired
dataUrl

The data URL.

Returns
ArrayBuffer | null | undefined

The array buffer with the data URL encoded as binary data.

dataToBlob

Function
Since
ArcGIS Maps SDK for JavaScript 4.33

Converts a base64 encoded data url to a Blob.

Signature
dataToBlob (dataUrl: string): Blob | null | undefined

Parameters

ParameterTypeDescriptionRequired
dataUrl

The data URL.

Returns
Blob | null | undefined

The blob with the data URL encoded as binary data.

downloadDataAsFile

Function
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

Parameters

ParameterTypeDescriptionRequired
dataUrl

The data URL.

filename

The filename.

Returns
void

downloadBlobAsFile

Function
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

Parameters

ParameterTypeDescriptionRequired
blob

The data URL to download (as binary data.

filename

The filename.

Returns
void

isHTTPSProtocol

Function
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

Parameters

ParameterTypeDescriptionRequired
url

The URL to test.

Returns
boolean

Returns true if the URL uses the https protocol, false otherwise.

Type definitions

UrlObject

Type definition

Converts the URL arguments to an object representation.

See also

path

Property
Type
string

the url path.

query

Property
Type
Record<string, string> | undefined

the url query.

hash

Property
Type
string | undefined

the url hash.

ProxyRule

Type definition

A proxy rule that matches a URL to a proxy URL.

See also

proxyUrl

Property
Type
string

The URL of the proxy.

urlPrefix

Property
Type
string

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