source: node_modules/@swagger-api/apidom-json-pointer/cjs/unescape.cjs

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 754 bytes
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5var _ramda = require("ramda");
6/**
7 * decodeURIComponent can throw URIError in certain cases like 'c%d'.
8 * safeDecodeURIComponent is a safe variant of decodeURIComponent that never trows.
9 *
10 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI|More info about URIError}
11 */
12const safeDecodeURIComponent = encodedURIComponent => {
13 try {
14 return decodeURIComponent(encodedURIComponent);
15 } catch {
16 return encodedURIComponent;
17 }
18};
19
20// unescape :: String -> String
21const unescape = (0, _ramda.pipe)((0, _ramda.replace)(/~1/g, '/'), (0, _ramda.replace)(/~0/g, '~'), safeDecodeURIComponent);
22var _default = exports.default = unescape;
Note: See TracBrowser for help on using the repository browser.