UNPKG

@wordpress/url

Version:
21 lines (20 loc) 568 B
/** * 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. */ export function getFragment(url) { var matches = /^\S+?(#[^\s\?]*)/.exec(url); if (matches) { return matches[1]; } } //# sourceMappingURL=get-fragment.js.map