@esri/arcgis-rest-request
Version:
Common methods and utilities for @esri/arcgis-rest-js packages.
23 lines • 766 B
JavaScript
;
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanUrl = void 0;
/**
* Helper method to ensure that user supplied urls don't include whitespace or a trailing slash.
*/
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;
}
exports.cleanUrl = cleanUrl;
//# sourceMappingURL=clean-url.js.map