require(["esri/urlUtils"], function(urlUtils) { /* code goes here */ });
Description
(Added at v3.8)
Utility methods for working with URLs.
When coding legacy (non-AMD) style, there is no need to require the module. All methods and properties are available in the namespace. For example,
esri.addProxyRule()
.
Samples
Search for
samples that use this class.
Methods
Method Details
Adds the given proxy rule to the proxy rules list: esri.config.defaults.io.proxyRules
Parameters:
<Object > rule |
Required |
The rule argument should have the following properties.
- proxyUrl - URL for the proxy.
- urlPrefix - URL prefix for resources that need to be accessed through the given proxy.
|
Returns the proxy rule that matches the given url.
Converts the URL arguments to an object representation. The object format is
{path: <String>, query:{key:<Object>}}
Parameters:
<String > url |
Required |
The input URL. |
Sample:
require([
"esri/urlUtils", ...
], function(urlUtils, ... ) {
var myObject = urlUtils.urlToObject("http://www.myworld.com?state_name=Ohio&city_name=Akron");
...
});
Returns:
{ path: "http://www.myworld.com", query: {state_name: "Ohio", city_name: "Akron"} }
If there are no query parameters the return value for query will be null:
{path:"http://www.myworld.com",query:null}
The following snippet shows how to check for null or undefined values.
var myObject = urlUtils.urlToObject("http://www.myworld.com");
if(myObject.query){
var query = myObject.query;
}