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