UNPKG

@bavenir/spade-node-js-client

Version:

A client-side JavaScript library that can be used to iteract with Data Broker's API.

29 lines (28 loc) 999 B
"use strict"; /** * Copyright (C) 2024 bAvenir * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitazeUrl = sanitazeUrl; /** * Removes the protocol (e.g., http://, https://), query parameters, and any trailing slash from a given URL. * * @param {string} url - The URL to be processed. * @returns {string} - The URL without the protocol, query parameters, and trailing slash. * * @example * const url = 'https://example.com/page/?param=value'; * console.log(removeProtocolAndQuery(url)); // Outputs: 'example.com/page' */ function sanitazeUrl(url) { return url .replace(/^[a-zA-Z]+:\/\//, '') // Remove protocol .replace(/\?.*$/, '') // Remove query parameters .replace(/\/$/, ''); // Remove trailing slash }