@wordpress/url
Version:
WordPress URL utilities.
28 lines (25 loc) • 651 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidFragment = isValidFragment;
/**
* Checks for invalid characters within the provided fragment.
*
* @param {string} fragment The url fragment.
*
* @example
* ```js
* const isValid = isValidFragment( '#valid-fragment' ); // true
* const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
* ```
*
* @return {boolean} True if the argument contains a valid fragment.
*/
function isValidFragment(fragment) {
if (!fragment) {
return false;
}
return /^#[^\s#?\/]*$/.test(fragment);
}
//# sourceMappingURL=is-valid-fragment.js.map