@esri/arcgis-rest-request
Version:
Common methods and utilities for @esri/arcgis-rest-js packages.
19 lines • 640 B
JavaScript
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
/**
* Helper method to ensure that user supplied urls don't include whitespace or a trailing slash.
*/
export function cleanUrl(url) {
// Guard so we don't try to trim something that's not a string
if (typeof url !== "string") {
return url;
}
// trim leading and trailing spaces, but not spaces inside the url
url = url.trim();
// remove the trailing slash to the url if one was included
if (url[url.length - 1] === "/") {
url = url.slice(0, -1);
}
return url;
}
//# sourceMappingURL=clean-url.js.map