UNPKG

@raona/sp

Version:

Raona utilities to work with Sharepoint using pnp/sp

43 lines (42 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Removes the part of the url after the query string (?) * @param url url to modify * @returns query string */ function stripQueryString(url) { return url.split('?')[0]; } exports.stripQueryString = stripQueryString; /** * Removes the part of the url after the hash (#) * @param url url to modify * @returns hash */ function stripHash(url) { return url.split('#')[0]; } exports.stripHash = stripHash; /** * Converts the provided Absolute url to relative url * @param url Absolute url * @returns relative url */ function toRelativeUrl(url, includeInitialSlash) { var protocolDelimiter = '://'; var delimiterLength = protocolDelimiter.length; var protocolIndex = url.indexOf(protocolDelimiter); return url.slice(url.indexOf('/', protocolIndex + delimiterLength) + (includeInitialSlash ? 0 : 1)); } exports.toRelativeUrl = toRelativeUrl; /** * Converts the provided Relative url to absolute url * @param url Relative url * @param location Location object (from Window or Document).location * @returns absolute url */ function toAbsoluteUrl(url, location) { return location.protocol + "//" + location.hostname + "/" + url; } exports.toAbsoluteUrl = toAbsoluteUrl;