UNPKG

@esri/arcgis-rest-request

Version:

Common methods and utilities for @esri/arcgis-rest-js packages.

22 lines 739 B
"use strict"; /* Copyright (c) 2018 Environmental Systems Research Institute, Inc. * Apache-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.cleanUrl = cleanUrl; /** * 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; } //# sourceMappingURL=clean-url.js.map