UNPKG

serde-fns

Version:

simple shapes and procedures for serde with a pit-of-success

19 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deSerialUriComponent = exports.asSerialUriComponent = exports.isSerialUriComponent = void 0; const type_fns_1 = require("type-fns"); exports.isSerialUriComponent = (0, type_fns_1.withAssure)((input) => { // see what the encoded string would have looked like const encodedExpected = (0, exports.asSerialUriComponent)((0, exports.deSerialUriComponent)(input)); // if its different to current state, then it must not have been encoded const encodedClaimed = input; if (encodedClaimed !== encodedExpected) return false; // otherwise, we were able to decode and re-encode and get the same result -> it was fully encoded return true; }); const asSerialUriComponent = (input) => encodeURIComponent(input); exports.asSerialUriComponent = asSerialUriComponent; const deSerialUriComponent = (input) => decodeURIComponent(input); exports.deSerialUriComponent = deSerialUriComponent; //# sourceMappingURL=uriComponent.js.map