UNPKG

@wordpress/url

Version:
28 lines (26 loc) 594 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.safeDecodeURI = safeDecodeURI; /** * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if * `decodeURI` throws an error. * * @param {string} uri URI to decode. * * @example * ```js * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' * ``` * * @return {string} Decoded URI if possible. */ function safeDecodeURI(uri) { try { return decodeURI(uri); } catch (uriError) { return uri; } } //# sourceMappingURL=safe-decode-uri.js.map