UNPKG

@wordpress/url

Version:
28 lines (25 loc) 677 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFragment = getFragment; /** * Returns the fragment part of the URL. * * @param {string} url The full URL * * @example * ```js * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' * ``` * * @return {string|void} The fragment part of the URL. */ function getFragment(url) { var matches = /^\S+?(#[^\s\?]*)/.exec(url); if (matches) { return matches[1]; } } //# sourceMappingURL=get-fragment.js.map