@jsonurl/jsonurl
Advanced tools
Comparing version
108
CHANGELOG.md
@@ -0,65 +1,99 @@ | ||
# v1.1.5 | ||
## Bug Fix | ||
* Fix bug in serializing number-like strings that include plus, with AQF ([@dmaccormack](https://github.com/dmaccormack "Link to profile for user dmaccormack")) | ||
## New Feature | ||
* ignore null array/object member parse option ([@dmaccormack](https://github.com/dmaccormack "Link to profile for user dmaccormack")) | ||
## Dependency Updates | ||
The following dependencies were updated: @babel/core, jsdom, multiple dependencies | ||
# v1.1.4 | ||
## Added | ||
- Add typescript declaration file [view commit](http://github.com/jsonurl/jsonurl-js/commit/13f1fd474b46ba68a544d9ae9a59a34bee0c8a4a) | ||
* Add typescript declaration file [view commit](http://github.com/jsonurl/jsonurl-js/commit/13f1fd474b46ba68a544d9ae9a59a34bee0c8a4a) | ||
## Changed | ||
- Update dependencies [view commit](http://github.com/jsonurl/jsonurl-js/commit/9dbebe2f823bb8de9f8a552c972933c1ad2f9866) | ||
* Update dependencies [view commit](http://github.com/jsonurl/jsonurl-js/commit/9dbebe2f823bb8de9f8a552c972933c1ad2f9866) | ||
# v1.1.3 | ||
Unpublished. | ||
# v1.1.2 | ||
## Changed | ||
- Fix interface regression [view commit](http://github.com/jsonurl/jsonurl-js/commit/e4c83f8f13035aa63218d7717442460fdfb27cda) | ||
* Fix interface regression [view commit](http://github.com/jsonurl/jsonurl-js/commit/e4c83f8f13035aa63218d7717442460fdfb27cda) | ||
# v1.1.1 | ||
## Added | ||
- Add support for AQF syntax [view commit](http://github.com/jsonurl/jsonurl-js/commit/65a1b09918b5005487b18aa5c66d8fd4a30309aa) | ||
- Add parse and stringify option noEmptyComposite [view commit](http://github.com/jsonurl/jsonurl-js/commit/202fb34b0da3d7358085bea7af2a21e441519b9f) | ||
- Add getMissingValue() parse option [view commit](http://github.com/jsonurl/jsonurl-js/commit/450d00c3127dc63b6606e7891219888b45e6241a) | ||
- Add support for coercing null to empty string on parse/stringify [view commit](http://github.com/jsonurl/jsonurl-js/commit/a564595b984283306ddee1d2aea6cb6d156098a3) | ||
- Add support for empty keys and empty string values [view commit](http://github.com/jsonurl/jsonurl-js/commit/6b94a0dadfc3d5ea8f21218f9bbee1205772f68b) | ||
* Add support for AQF syntax [view commit](http://github.com/jsonurl/jsonurl-js/commit/65a1b09918b5005487b18aa5c66d8fd4a30309aa) | ||
* Add parse and stringify option noEmptyComposite [view commit](http://github.com/jsonurl/jsonurl-js/commit/202fb34b0da3d7358085bea7af2a21e441519b9f) | ||
* Add getMissingValue() parse option [view commit](http://github.com/jsonurl/jsonurl-js/commit/450d00c3127dc63b6606e7891219888b45e6241a) | ||
* Add support for coercing null to empty string on parse/stringify [view commit](http://github.com/jsonurl/jsonurl-js/commit/a564595b984283306ddee1d2aea6cb6d156098a3) | ||
* Add support for empty keys and empty string values [view commit](http://github.com/jsonurl/jsonurl-js/commit/6b94a0dadfc3d5ea8f21218f9bbee1205772f68b) | ||
## Changed | ||
- Ignore extraneous ampersands for wfu-implied-composite values [view commit](http://github.com/jsonurl/jsonurl-js/commit/f288b33fbe9e8e88450a56d0878155dd85c85d1d) | ||
- Upgrade dependencies [view commit](http://github.com/jsonurl/jsonurl-js/commit/045008b511250f9da45ce3f85ed16a05a3b887b4) | ||
- Fix bug when encoding more than one left/right paren in string literal [view commit](http://github.com/jsonurl/jsonurl-js/commit/217ef164776a4fa5c2bd8361fdc5e06b6c0a3c84) | ||
- Upgrade multiple dependencies | ||
* Ignore extraneous ampersands for wfu-implied-composite values [view commit](http://github.com/jsonurl/jsonurl-js/commit/f288b33fbe9e8e88450a56d0878155dd85c85d1d) | ||
* Upgrade dependencies [view commit](http://github.com/jsonurl/jsonurl-js/commit/045008b511250f9da45ce3f85ed16a05a3b887b4) | ||
* Fix bug when encoding more than one left/right paren in string literal [view commit](http://github.com/jsonurl/jsonurl-js/commit/217ef164776a4fa5c2bd8361fdc5e06b6c0a3c84) | ||
* Upgrade multiple dependencies | ||
# v1.0.3 | ||
## Added | ||
- Added support for implied string literals [view commit](http://github.com/jsonurl/jsonurl-js/commit/1ff72c6c590be33eb9792e3f26086d893e137534) | ||
* Added support for implied string literals [view commit](http://github.com/jsonurl/jsonurl-js/commit/1ff72c6c590be33eb9792e3f26086d893e137534) | ||
# v1.0.2 | ||
## Added | ||
- Add support for x-www-form-urlencoded style separators [view commit](http://github.com/jsonurl/jsonurl-js/commit/2faa2482a176d69f8297f7ab095178dba164d74f) | ||
* Add support for x-www-form-urlencoded style separators [view commit](http://github.com/jsonurl/jsonurl-js/commit/2faa2482a176d69f8297f7ab095178dba164d74f) | ||
## Changed | ||
- update: Fix edge case of apos followed by string literal [view commit](http://github.com/jsonurl/jsonurl-js/commit/4dc2f185bd4862fbe83f49857eca136142c7639e) | ||
- doc: Mark non-exported classes as private [view commit](http://github.com/jsonurl/jsonurl-js/commit/271ab69e76448002692801ff065bb67ac939415f) | ||
- upgrade @babel/cli to 7.11.6 | ||
- upgrade eslint to 7.9.0 | ||
- upgrade eslint-plugin-jest to 23.18.0 | ||
- upgrade jest to 26.4.2 | ||
- upgrade jsdoc to 3.6.6 | ||
- upgrade prettier to 2.1.2 | ||
- upgrade rollup to 2.28.1 | ||
- upgrade @rollup/plugin-babel to 5.2.1 | ||
- upgrade rollup-plugin-terser to 7.0.2 | ||
* update: Fix edge case of apos followed by string literal [view commit](http://github.com/jsonurl/jsonurl-js/commit/4dc2f185bd4862fbe83f49857eca136142c7639e) | ||
* doc: Mark non-exported classes as private [view commit](http://github.com/jsonurl/jsonurl-js/commit/271ab69e76448002692801ff065bb67ac939415f) | ||
* upgrade @babel/cli to 7.11.6 | ||
* upgrade eslint to 7.9.0 | ||
* upgrade eslint-plugin-jest to 23.18.0 | ||
* upgrade jest to 26.4.2 | ||
* upgrade jsdoc to 3.6.6 | ||
* upgrade prettier to 2.1.2 | ||
* upgrade rollup to 2.28.1 | ||
* upgrade @rollup/plugin-babel to 5.2.1 | ||
* upgrade rollup-plugin-terser to 7.0.2 | ||
# v1.0.1 | ||
## Added | ||
- Add support for implied arrays and objects [view commit](http://github.com/jsonurl/jsonurl-js/commit/ee83d9c5c6d6cbc1643c721ba223a004ee4e8781) | ||
- Add JSDoc support [view commit](http://github.com/jsonurl/jsonurl-js/commit/5706a2975632201ef574b23dc38d00bb2a154737) | ||
* Add support for implied arrays and objects [view commit](http://github.com/jsonurl/jsonurl-js/commit/ee83d9c5c6d6cbc1643c721ba223a004ee4e8781) | ||
* Add JSDoc support [view commit](http://github.com/jsonurl/jsonurl-js/commit/5706a2975632201ef574b23dc38d00bb2a154737) | ||
## Changed | ||
- upgrade @babel/preset-env to 7.10.4 [view commit](http://github.com/jsonurl/jsonurl-js/commit/0e2019124c303847e21aa2bb0a63ef3bf528a64d) | ||
- upgrade rollup to 2.18.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/ef9ded9e4df15d0d2404f29245e80cc7ae161255) | ||
- upgrade lodash from 4.17.19 [view commit](http://github.com/jsonurl/jsonurl-js/commit/0d78ec646e2731923163fb9641995b5087e82b15) | ||
- upgrade eslint from to 7.3.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/131e5b073e7823d81f480b1f077f8dd1be3299b9) | ||
- upgrade eslint-plugin-prettier to 3.1.4 [view commit](http://github.com/jsonurl/jsonurl-js/commit/80b350a03e894b63a1e34a3cc362635b4f0ea532) | ||
- upgrade eslint-plugin-jest to 23.17.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/684957f78145c30bf2c306a644cb1be4268b7501) | ||
- Do not mix named and default exports [view commit](http://github.com/jsonurl/jsonurl-js/commit/dd772cae0c3501cec252a1ed42387de514b9c6a3) | ||
- Split the test suite into multiple files [view commit](http://github.com/jsonurl/jsonurl-js/commit/60cf88e968e7c408722dc16404150197529feeab) | ||
- Rename main.js -> JsonURL.js [view commit](http://github.com/jsonurl/jsonurl-js/commit/ee83d9c5c6d6cbc1643c721ba223a004ee4e8781) | ||
* upgrade @babel/preset-env to 7.10.4 [view commit](http://github.com/jsonurl/jsonurl-js/commit/0e2019124c303847e21aa2bb0a63ef3bf528a64d) | ||
* upgrade rollup to 2.18.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/ef9ded9e4df15d0d2404f29245e80cc7ae161255) | ||
* upgrade lodash from 4.17.19 [view commit](http://github.com/jsonurl/jsonurl-js/commit/0d78ec646e2731923163fb9641995b5087e82b15) | ||
* upgrade eslint from to 7.3.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/131e5b073e7823d81f480b1f077f8dd1be3299b9) | ||
* upgrade eslint-plugin-prettier to 3.1.4 [view commit](http://github.com/jsonurl/jsonurl-js/commit/80b350a03e894b63a1e34a3cc362635b4f0ea532) | ||
* upgrade eslint-plugin-jest to 23.17.1 [view commit](http://github.com/jsonurl/jsonurl-js/commit/684957f78145c30bf2c306a644cb1be4268b7501) | ||
* Do not mix named and default exports [view commit](http://github.com/jsonurl/jsonurl-js/commit/dd772cae0c3501cec252a1ed42387de514b9c6a3) | ||
* Split the test suite into multiple files [view commit](http://github.com/jsonurl/jsonurl-js/commit/60cf88e968e7c408722dc16404150197529feeab) | ||
* Rename main.js -> JsonURL.js [view commit](http://github.com/jsonurl/jsonurl-js/commit/ee83d9c5c6d6cbc1643c721ba223a004ee4e8781) | ||
# v1.0.0 | ||
- Initial release | ||
* Initial release |
@@ -12,8 +12,5 @@ Contributing to jsonurl-js | ||
+ If you just want to make a small change see "Making Trivial Changes" below. | ||
+ If you're planning to implement a new feature it's a good idea to discuss | ||
it on [Zulip][zulip] first. | ||
This can help make sure you're not wasting your time on something that's | ||
considered out of scope. | ||
+ See if there is already an | ||
[issue](https://github.com/jsonurl/jsonurl-java/issues), | ||
+ See if there is already a | ||
[discussion][discussion] or | ||
[issue](https://github.com/jsonurl/jsonurl-js/issues), | ||
or create a new one if necessary | ||
@@ -23,2 +20,6 @@ + For defects, clearly describe the problem, including steps to reproduce | ||
use cases | ||
+ If you're planning to implement a new feature it's a good idea to | ||
[discuss][discussion] it first. | ||
This can help make sure you're not wasting your time on something that's | ||
considered out of scope. | ||
+ Fork the repository on GitHub. | ||
@@ -28,10 +29,20 @@ | ||
-------------- | ||
I accept pull requests via GitHub. [Zulip][zulip] is | ||
the main channel of communication for contributors. | ||
Here are some guidelines which will make applying PRs easier for me: | ||
+ Create a topic/feature branch from the `master` branch to base your work, and | ||
push your changes to a topic branch in your fork of the repository | ||
I accept pull requests via GitHub. Here are some guidelines which will make | ||
applying PRs easier for me: | ||
+ Create a topic/feature branch from the `main` branch to base your work, and | ||
push your changes to that branch in your fork of the repository | ||
+ Make commits of logical units and with [meaningful][commit-message-howto], | ||
[semantic][semantic-commit-message] messages that reference the related | ||
GitHub issue | ||
[conventional commit][cc] messages that reference the related | ||
GitHub issue. The following commit types are currently in use: | ||
+ feat - A new feature | ||
+ fix - A bug fix | ||
+ docs - Documentation changes | ||
+ style - Changes that do not affect code execution (e.g. formatting) | ||
+ refactor - A code change that neither fixes a bug nor adds a feature | ||
+ perf - A code change that improves performance | ||
+ test - A change to test configuration, or one or more files in the `test` | ||
directory; must not affect the result of `npm run build` | ||
+ chore - Changes to the build or workflow process; must not affect the | ||
result of `npm run build` | ||
+ update - dependency update | ||
+ Use the [style][eslintrc.js] of the existing codebase | ||
@@ -45,9 +56,11 @@ + Make sure you have added/updated tests for your changes, and that all tests | ||
For small changes, like tweaks to comments and/or documentation you don't need | ||
to create an issue. A fork + PR with a proper commit message (i.e. doc: ...) | ||
to create an issue. A fork + PR with a proper commit message (i.e. docs: ...) | ||
is sufficient. | ||
[zulip]: https://jsonurl.zulipchat.com/#narrow/stream/248637-jsonurl-js | ||
[discussion]: https://github.com/jsonurl/jsonurl-js/discussions | ||
[eslintrc.js]: .eslintrc.js | ||
[commit-message-howto]: https://chris.beams.io/posts/git-commit/ | ||
[semantic-commit-message]: https://seesparkbox.com/foundry/semantic_commit_messages | ||
[cc]: https://www.conventionalcommits.org/en/v1.0.0/ | ||
/*! | ||
* jsonurl.js v1.1.4 | ||
* jsonurl.js v1.1.5 | ||
* (c) 2021 David MacCormack | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,r){return(a=s()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,e)})(e)}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){var t=s();return function(){var r,n=i(e);if(t){var o=i(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}var l="JSON->URL: expected literal value",h="JSON->URL: unexpected character",f="JSON->URL: unexpected end of text inside composite",d="JSON->URL: unexpected text after composite",y="JSON->URL: MaxParseValues exceeded",v="JSON->URL: the empty string is not allowed",w="JSON->URL: invalid escape sequence",m="JSON->URL: invalid percent-encoded sequence",x="JSON->URL: expected object value";function O(e,t){return void 0===t?e:e+" at position "+t}var b=16,E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function g(e){return e>127?0:E[e]}var A=function(){function t(r){e(this,t),this.setOrDefault(r,"allowEmptyUnquotedValues"),this.setOrDefault(r,"allowEmptyUnquotedKeys"),this.setOrDefault(r,"AQF"),this.setOrDefault(r,"coerceNullToEmptyString"),this.setOrDefault(r,"impliedArray"),this.setOrDefault(r,"impliedObject"),this.setOrDefault(r,"impliedStringLiterals"),this.setOrDefault(r,"noEmptyComposite"),this.setOrDefault(r,"wwwFormUrlEncoded")}return r(t,[{key:"setOrDefault",value:function(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}},{key:"setOverride",value:function(e,t){void 0!==e&&t in e&&(this[t]=e[t])}},{key:"setOrDefaultInt",value:function(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}}]),t}(),S=function(t){n(o,t);var i=p(o);function o(t,r){var n;return e(this,o),(n=i.call(this,t)).setOrDefault(t,"emptyValue"),n.setOrDefault(r,"emptyValue",{}),n.setOverride(t,"getMissingValue"),n.setOrDefaultInt(t,"maxParseChars"),n.setOrDefaultInt(r,"maxParseChars",32768),n.setOrDefaultInt(t,"maxParseDepth"),n.setOrDefaultInt(r,"maxParseDepth",32),n.setOrDefaultInt(t,"maxParseValues"),n.setOrDefaultInt(r,"maxParseValues",4096),n.setOrDefault(t,"nullValue"),n.setOrDefault(r,"nullValue",null),n}return r(o,[{key:"getMissingValue",value:function(e,t){throw new SyntaxError(O(x,t))}}]),o}(A),V=function(t){n(i,t);var r=p(i);function i(t){var n;e(this,i),n=r.call(this,t);var o=!(void 0===t||!("impliedStringLiterals"in t)||!t.impliedStringLiterals)||void 0;return n.setOrDefault(t,"allowEmptyUnquotedValues",o),n.setOrDefault(t,"allowEmptyUnquotedKeys",o),n.setOrDefault(t,"callFunctions"),n.setOrDefault(t,"isImplied"),n.setOrDefault(t,"ignoreNullArrayMembers",o),n.setOrDefault(t,"ignoreNullObjectMembers",o),n.setOrDefault(t,"ignoreUndefinedArrayMembers",o),n.setOrDefault(t,"ignoreUndefinedObjectMembers",o),n.isImplied=n.isImplied||n.impliedArray||n.impliedObject,n}return i}(A),k=/\+/g,L=/ /g,U=/(![\s\S]?)/g,C=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,j=/^[-A-Za-z0-9._~!$*,;=@?/(),: ]+$/,D=/^(?:true|false|null|(?:[-]?[0-9]+(?:[.][0-9]+)?(?:[eE][-+]?[0-9]+)?))$/,P=/[(),:]|%2[04]|%3B/gi,R={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},N=/[!(),:]|%2[01489C]|%3[AB]/gi,F={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},J=40,I=41,T=44,M=58,q=38,_=48,$=65,B=97,Q=new Array(111);Q[33]="!",Q[40]="(",Q[41]=")",Q[43]="+",Q[44]=",",Q[45]=",",Q[48]="0",Q[49]="1",Q[50]="2",Q[51]="3",Q[52]="4",Q[53]="5",Q[54]="6",Q[55]="7",Q[56]="8",Q[57]="9",Q[58]=":",Q[116]="t",Q[102]="f",Q[110]="n";var K="",z=" ";function Z(e,t){var r=t?N:P,n=t?F:R;return encodeURIComponent(e).replace(r,(function(e){var t=n[e];return void 0===t?e:t}))}function G(e,t){switch(t){case _:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case $:case B:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(O(m,e))}}function H(e){if(e.coerceNullToEmptyString)return W(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function W(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return K;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(v);return"''"}Object.defineProperty(Array.prototype,"toJsonURLText",{value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0;return this.forEach((function(n){if("function"==typeof n){if(!e.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(e.ignoreUndefinedArrayMembers)return;n=H(e)}else if(null===n){if(e.ignoreNullArrayMembers)return;n=H(e)}else n=n.toJsonURLText(e,t+1);void 0===r?r=n:!e.wwwFormUrlEncoded||t>0?r+=","+n:r+="&"+n})),!e.isImplied||t>0?void 0===r?"()":"("+r+")":void 0===r?K:r}}),Object.defineProperty(Boolean.prototype,"toJsonURLText",{value:function(){return!0===this?"true":"false"}}),Object.defineProperty(Number.prototype,"toJsonURLText",{value:function(e){var t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?Z(t,e):t}}),Object.defineProperty(Object.prototype,"toJsonURLText",{value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0,n=Object.keys(this),i=this;return n.forEach((function(n){if(null!=n){var o=i[n];if("function"==typeof o){if(!e.callFunctions)return;for(;"function"==typeof o;)o=o()}if(void 0===o){if(e.ignoreUndefinedObjectMembers)return;o=H(e)}else if(null===o){if(e.ignoreNullObjectMembers)return;o=H(e)}else o=o.toJsonURLText(e,t+1);var s=n.toJsonURLText(e,t,!0);void 0===r?r=!e.wwwFormUrlEncoded||t>0?s+":"+o:s+"="+o:!e.wwwFormUrlEncoded||t>0?r+=","+s+":"+o:r+="&"+s+"="+o}})),!e.isImplied||t>0?(e.noEmptyComposite&&void 0===r&&(r=":"),void 0===r?"()":"("+r+")"):void 0===r?K:r}}),Object.defineProperty(String.prototype,"toJsonURLText",{value:function(e,t,r){if(0===this.length)return W(e,r);if(e.impliedStringLiterals)return Z(this,e.AQF);if(D.test(this))return!0===r?this:e.AQF?"!"+this:-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);if(e.AQF)return Z(this,!0);if(C.test(this))return-1==this.indexOf(z)?this:this.replace(L,"+");if(j.test(this))return-1==this.indexOf(z)?"'"+this+"'":"'"+this.replace(L,"+")+"'";var n=Z(this);return 39==n.charCodeAt(0)?"%27"+n.substring(1):n}});var X=function(){function t(r,n,i,o){e(this,t),this.text=r,this.pos=this.markPos=n,this.end=i,this.options=o}return r(t,[{key:"skipAmps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.text,r=this.end,n=this.pos;if(e)for(;n<r&&t.charCodeAt(n)===q;)n++;else if(n<r&&t.charCodeAt(n)===q){for(n++;n<r&&t.charCodeAt(n)===q;n++);n!==r&&n--}this.pos=n}},{key:"structChar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){var t=this.text.charCodeAt(this.pos);switch(t){case q:case 61:if(e)return;return this.pos++,t}}var r=this.pos,n=this.ordinal();switch(n){case T:case M:if(e)return void(this.pos=r);case J:case I:return n;default:return void(this.pos=r)}}},{key:"ordinal",value:function(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}},{key:"accept",value:function(e){var t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}},{key:"acceptPlus",value:function(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}},{key:"done",value:function(){return this.end<=this.pos}},{key:"validateLiteral",value:function(e,t){for(var r=this.text,n=this.end;e<n;e++){switch(g(r.charCodeAt(e))&t){case 0:throw new SyntaxError(O(h,e));case b:return e;case 8:return e+1;default:continue}}}},{key:"findLiteralEnd",value:function(){var e=this.text,t=this.end,r=this.pos,n=39===e.charCodeAt(r);n&&r++;var i=n?28:18;if(void 0!==(r=this.validateLiteral(r,i)))return r;if(n)throw new SyntaxError(O("JSON->URL: quoted string still open",r));return t}},{key:"isEmptyObject",value:function(){if(this.options.noEmptyComposite){var e=this.pos;if(!this.accept(M))return!1;var t=this.pos,r=this.accept(I);return this.pos=r?t:e,r}return!1}},{key:"parseLiteral",value:function(e){var t=this.pos,r=this.options,n=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(n)==M),n<=t)return function(e,t){if(t)return K;throw new SyntaxError(O(v,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues);if(!0===r.impliedStringLiterals)return this.parseStringLiteral(n,!0);var i=this.parseTrueFalseNull(n,e);if(void 0!==i)return i;var o=this.parseNumberLiteral(n,e);return void 0!==o?o:this.parseStringLiteral(n,!1)}},{key:"parseDigits",value:function(e){for(var t,r=!1;this.pos<e;)switch(this.ordinal()){case _:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}},{key:"parseExponentValue",value:function(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}},{key:"parseExponent",value:function(e){var t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}},{key:"parseFraction",value:function(e){var t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}},{key:"parseInteger",value:function(e){return!(e<=this.pos)&&(!!this.accept(_)||this.parseDigits(e))}},{key:"parseNumberLiteral",value:function(e,t){var r=this.text,n=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){var i=decodeURIComponent(r.substring(n,e));return t?i:Number(i)}this.pos=n}},{key:"parseStringLiteral",value:function(e,t){var r=this.text,n=this.pos,i=t||39!==r.charCodeAt(n)?r.substring(n,e):r.substring(n+1,e-1);return i=decodeURIComponent(i.replace(k,z)),this.pos=e,i}},{key:"parseTrueFalseNull",value:function(e,t){var r,n,i,o,s,a=this.text,u=this.pos;switch(e-u){case 4:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),116===r&&114===n&&117===i&&101===o)return this.pos=e,!t||"true";if(110===r&&117===n&&108===i&&108===o)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),s=a.charCodeAt(u+4),102===r&&n===B&&108===i&&115===o&&101===s)return this.pos=e,!!t&&"false"}}},{key:"newEmptyValue",value:function(){var e=this.options;if(e.noEmptyComposite)return[];var t=e.emptyValue;return"function"==typeof t?t():t}},{key:"newNullValue",value:function(){var e=this.options,t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=K),t}}]),t}(),Y=function(t){n(o,t);var i=p(o);function o(t,r,n,s){return e(this,o),i.call(this,t,r,n,s)}return r(o,[{key:"ordinal",value:function(e){var t,r,n=e||this.pos,i=this.text.charCodeAt(n);return 37===i?(t=function(e,t,r){if(r<=t+1)throw new SyntaxError(O(m,t));return G(t,e.charCodeAt(t))<<4|G(t,e.charCodeAt(t+1))}(this.text,n+1,this.end),r=3):(t=i,r=1),void 0===e&&(this.pos+=r),t}},{key:"acceptPlus",value:function(){return this.accept(43)}},{key:"findLiteralEnd",value:function(){for(var e=this.end,t=this.pos,r=this.text,n=t;;){if(e<=this.pos)return this.pos=t,e;switch(50&g(r.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return n=this.pos,this.pos=t,n;case 0:throw new SyntaxError(O(h,n))}switch(this.ordinal()){case J:case I:case M:case T:return this.pos=t,n;case 33:if(this.pos===e)throw new SyntaxError(O(w,n));this.ordinal(),n=this.pos;break;default:n=this.pos}}}},{key:"parseStringLiteral",value:function(e){var t=this.text,r=this.pos,n=decodeURIComponent(t.substring(r,e).replace(k,z));return this.pos=e,"!e"===n?K:n.replace(U,(function(e,t,n){if(2===e.length){var i=e.charCodeAt(1),o=Q[i];if(void 0!==o)return o}throw new SyntaxError(O(w,r+n))}))}}]),o}(X),ee=function(t){n(o,t);var i=p(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.parseDepth=0,r}return r(o,[{key:"replaceAndPush",value:function(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(O("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}},{key:"replace",value:function(e){this[this.parseDepth]=e}},{key:"depth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&(this.parseDepth--,this.pop()),this.parseDepth}}]),o}(u(Array)),te=function(t){n(o,t);var i=p(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.numValues=0,r}return r(o,[{key:"popObjectValue",value:function(e){e=e||this.pop();var t=this.pop(),r=this[this.length-1];return r[t]=e,r}},{key:"popArrayValue",value:function(e){e=e||this.pop();var t=this[this.length-1];return t.push(e),t}},{key:"checkValueLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(O(y,e))}},{key:"appendArrayValue",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}]),o}(u(Array));function re(e){for(;"function"==typeof e;)e=e();return e}function ne(e,t,r,n){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=re(r))instanceof S||(r=new S(r,n)),r}function ie(e,t,r,n){return n.AQF?new Y(e,t,r,n):new X(e,t,r,n)}function oe(e,t){return"number"==typeof e?e:t}function se(e,t,r,n,i){if(void 0!==e){n=ne(t,r,n,i),e=String(e);var o=oe(t,0),s=oe(r,e.length);if(s<=o){if(void 0!==n.impliedArray)return n.impliedArray;if(void 0!==n.impliedObject)return n.impliedObject;throw new SyntaxError(O("JSON->URL: expected value",0))}if(s>n.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");var a=n.wwwFormUrlEncoded&&(n.impliedObject||n.impliedArray),u=new te(n),c=new ee(n),p=ie(e,o,s,n);if(void 0!==n.impliedObject)u.push(n.impliedObject),c.push(6);else if(void 0!==n.impliedArray)u.push(n.impliedArray),c.push(2);else{if(p.structChar(!0)!==J){var y=p.parseLiteral(!1);if(p.done())return y;throw new SyntaxError(O(l,0))}c.push(1)}for(a&&p.skipAmps(!0);;){if(p.done())throw new SyntaxError(O(f,p.pos));var v=void 0,w=void 0,m=void 0;switch(c[c.depth()]){case 1:switch(p.structChar(!0)){case J:u.appendArrayValue(p.pos,[]),c.replaceAndPush(p.pos,3,1);continue;case I:if(-1===c.depth(!0)){if(p.done())return p.newEmptyValue();throw new SyntaxError(O(d,p.pos))}if(u.appendArrayValue(p.pos,p.newEmptyValue()),0===c.depth()&&(a&&p.skipAmps(),p.done())){if(n.impliedArray)return u.popArrayValue();if(n.impliedObject)return u.popObjectValue();throw new SyntaxError(O(f,p.pos))}continue}switch(u.checkValueLimit(p.pos),v=(w=p.isEmptyObject())?{}:p.parseLiteral(),m=p.pos,p.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case T:c.replace(2),u.appendArrayValue(m,[]),u.push(v),u.popArrayValue();continue;case I:switch(w?u.push({}):u.appendArrayValue(m,[v]),c.depth(!0)){case-1:if(p.pos===s)return u[0];throw new SyntaxError(O(d,m));case 0:if(a&&p.skipAmps(),p.done()){if(n.impliedArray)return u.popArrayValue();if(n.impliedObject)return u.popObjectValue();throw new SyntaxError(O(f,m))}}continue;case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case M:c.replace(4),u.push({},v);continue;default:throw new SyntaxError(O(l,m))}case 2:if(p.accept(J)){c.replaceAndPush(p.pos,3,1);continue}if(u.checkValueLimit(p.pos),v=p.parseLiteral(!1),a&&p.skipAmps(),p.done()){if(0===c.depth()&&n.impliedArray)return u.popArrayValue(v);throw new SyntaxError(O(f,s))}c.replace(3),u.push(v);continue;case 3:switch(u.popArrayValue(),p.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,p.pos));case T:c.replace(2);continue;case I:switch(c.depth(!0)){case-1:if(p.done()&&!n.impliedArray)return u[0];throw new SyntaxError(O(d,p.pos));case 0:if(a&&p.skipAmps(),p.done()){if(n.impliedArray)return u.popArrayValue();if(n.impliedObject)return u.popObjectValue();throw new SyntaxError(O(f,p.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma or close paren",p.pos));case 4:if(p.accept(J)){c.replaceAndPush(p.pos,5,1);continue}if(u.checkValueLimit(p.pos),v=p.parseLiteral(!1),a&&p.skipAmps(),p.done()){if(0===c.depth()&&n.impliedObject)return u.popObjectValue(v);throw new SyntaxError(O(f,s))}c.replace(5),u.push(v);continue;case 5:switch(u.popObjectValue(),m=p.pos,p.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case T:c.replace(6);continue;case I:switch(c.depth(!0)){case-1:if(p.done()&&!n.impliedObject)return u[0];throw new SyntaxError(O(d,p.pos));case 0:if(a&&p.skipAmps(),p.done()){if(n.impliedArray)return u.popArrayValue();if(n.impliedObject)return u.popObjectValue();throw new SyntaxError(O(d,p.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma, open paren, or close paren",p.pos));case 6:if(v=p.parseLiteral(!0),a&&p.skipAmps(),p.done()){if(n.impliedObject&&0==c.depth())return u.push(v,n.getMissingValue(v)),u.popObjectValue();throw new SyntaxError(O(f,s))}switch(p.structChar()){case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,p.pos));case M:break;case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,p.pos));case T:if(n.impliedObject&&0==c.depth()){u.push(v,n.getMissingValue(v)),u.popObjectValue();continue}default:throw new SyntaxError(O(x,p.pos))}c.replace(4),u.push(v);continue;default:throw new SyntaxError(O("JSON->URL: internal error",p.pos))}}}}return function(){function t(r){for(e(this,t);"function"==typeof r;)r=r();void 0===r&&(r={}),this.maxParseDepth="number"==typeof r.maxParseDepth?parseInt(r.maxParseDepth):32,this.maxParseValues="number"==typeof r.maxParseValues?parseInt(r.maxParseValues):4096,this.maxParseChars="number"==typeof r.maxParseChars?parseInt(r.maxParseChars):32768,this.emptyValue=void 0===r.emptyValue?{}:r.emptyValue,this.nullValue=void 0===r.nullValue?null:r.nullValue}return r(t,[{key:"parseLiteral",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);var o=ie(e,t,r,ne(i));return o.parseLiteral(n)}},{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,this)}}],[{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,void 0)}},{key:"stringify",value:function(e,t){if(void 0!==e)return t=new V(re(t)),null===e?H(t):e.toJsonURLText(t,0)}}]),t}()})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,r){return(a=s()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,e)})(e)}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=s();return function(){var r,n=i(e);if(t){var o=i(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}var p="JSON->URL: expected literal value",h="JSON->URL: unexpected character",f="JSON->URL: unexpected end of text inside composite",d="JSON->URL: unexpected text after composite",y="JSON->URL: MaxParseValues exceeded",v="JSON->URL: the empty string is not allowed",w="JSON->URL: invalid escape sequence",m="JSON->URL: invalid percent-encoded sequence",x="JSON->URL: expected object value";function O(e,t){return void 0===t?e:e+" at position "+t}var b=16,A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function g(e){return e>127?0:A[e]}var E=function(){function t(r){e(this,t),this.setOrDefault(r,"allowEmptyUnquotedValues"),this.setOrDefault(r,"allowEmptyUnquotedKeys"),this.setOrDefault(r,"AQF"),this.setOrDefault(r,"coerceNullToEmptyString"),this.setOrDefault(r,"ignoreNullArrayMembers"),this.setOrDefault(r,"ignoreNullObjectMembers"),this.setOrDefault(r,"impliedArray"),this.setOrDefault(r,"impliedObject"),this.setOrDefault(r,"impliedStringLiterals"),this.setOrDefault(r,"noEmptyComposite"),this.setOrDefault(r,"wwwFormUrlEncoded")}return r(t,[{key:"setOrDefault",value:function(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}},{key:"setOverride",value:function(e,t){void 0!==e&&t in e&&(this[t]=e[t])}},{key:"setOrDefaultInt",value:function(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}},{key:"isPresentAndTrue",value:function(e){return e in this&&this[e]}}]),t}(),S=function(t){n(o,t);var i=l(o);function o(t,r){var n;return e(this,o),(n=i.call(this,t)).setOrDefault(t,"emptyValue"),n.setOrDefault(r,"emptyValue",{}),n.setOverride(t,"getMissingValue"),n.setOrDefaultInt(t,"maxParseChars"),n.setOrDefaultInt(r,"maxParseChars",32768),n.setOrDefaultInt(t,"maxParseDepth"),n.setOrDefaultInt(r,"maxParseDepth",32),n.setOrDefaultInt(t,"maxParseValues"),n.setOrDefaultInt(r,"maxParseValues",4096),n.setOrDefault(t,"nullValue"),n.setOrDefault(r,"nullValue",null),n}return r(o,[{key:"getMissingValue",value:function(e,t){throw new SyntaxError(O(x,t))}}]),o}(E),V=function(t){n(i,t);var r=l(i);function i(t){var n;e(this,i),n=r.call(this,t);var o=!(void 0===t||!("impliedStringLiterals"in t)||!t.impliedStringLiterals)||void 0;return n.setOrDefault(t,"allowEmptyUnquotedValues",o),n.setOrDefault(t,"allowEmptyUnquotedKeys",o),n.setOrDefault(t,"callFunctions"),n.setOrDefault(t,"isImplied"),n.setOrDefault(t,"ignoreNullArrayMembers",o),n.setOrDefault(t,"ignoreNullObjectMembers",o),n.setOrDefault(t,"ignoreUndefinedArrayMembers",o),n.setOrDefault(t,"ignoreUndefinedObjectMembers",o),n.isImplied=n.isImplied||n.impliedArray||n.impliedObject,n}return i}(E),k=/\+/g,L=/ /g,U=/(![\s\S]?)/g,C=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,j=/^[-A-Za-z0-9._~!$*,;=@?/(),: ]+$/,D=/^(?:true|false|null|(?:[-]?[0-9]+(?:[.][0-9]+)?(?:[eE][-+]?[0-9]+)?))$/,P=/[(),:]|%2[04]|%3B/gi,R={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},N=/[!(),:]|%2[01489C]|%3[AB]/gi,F={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},J=40,I=41,T=44,M=58,q=38,_=48,$=65,B=97,Q=new Array(111);Q[33]="!",Q[40]="(",Q[41]=")",Q[43]="+",Q[44]=",",Q[45]=",",Q[48]="0",Q[49]="1",Q[50]="2",Q[51]="3",Q[52]="4",Q[53]="5",Q[54]="6",Q[55]="7",Q[56]="8",Q[57]="9",Q[58]=":",Q[116]="t",Q[102]="f",Q[110]="n";var K="",z=" ";function Z(e,t){var r=t?N:P,n=t?F:R;return encodeURIComponent(e).replace(r,(function(e){var t=n[e];return void 0===t?e:t}))}function G(e,t){switch(t){case _:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case $:case B:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(O(m,e))}}function H(e){if(e.coerceNullToEmptyString)return W(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function W(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return K;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(v);return"''"}Object.defineProperty(Array.prototype,"toJsonURLText",{value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0;return this.forEach((function(n){if("function"==typeof n){if(!e.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(e.ignoreUndefinedArrayMembers)return;n=H(e)}else if(null===n){if(e.ignoreNullArrayMembers)return;n=H(e)}else n=n.toJsonURLText(e,t+1);void 0===r?r=n:!e.wwwFormUrlEncoded||t>0?r+=","+n:r+="&"+n})),!e.isImplied||t>0?void 0===r?"()":"("+r+")":void 0===r?K:r}}),Object.defineProperty(Boolean.prototype,"toJsonURLText",{value:function(){return!0===this?"true":"false"}}),Object.defineProperty(Number.prototype,"toJsonURLText",{value:function(e){var t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?Z(t,e):t}}),Object.defineProperty(Object.prototype,"toJsonURLText",{value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0,n=Object.keys(this),i=this;return n.forEach((function(n){if(null!=n){var o=i[n];if("function"==typeof o){if(!e.callFunctions)return;for(;"function"==typeof o;)o=o()}if(void 0===o){if(e.ignoreUndefinedObjectMembers)return;o=H(e)}else if(null===o){if(e.ignoreNullObjectMembers)return;o=H(e)}else o=o.toJsonURLText(e,t+1);var s=n.toJsonURLText(e,t,!0);void 0===r?r=!e.wwwFormUrlEncoded||t>0?s+":"+o:s+"="+o:!e.wwwFormUrlEncoded||t>0?r+=","+s+":"+o:r+="&"+s+"="+o}})),!e.isImplied||t>0?(e.noEmptyComposite&&void 0===r&&(r=":"),void 0===r?"()":"("+r+")"):void 0===r?K:r}}),Object.defineProperty(String.prototype,"toJsonURLText",{value:function(e,t,r){if(0===this.length)return W(e,r);if(e.impliedStringLiterals)return Z(this,e.AQF);if(D.test(this))return!0===r?this:e.AQF?-1==this.indexOf("+")?"!"+this:this.replace("+","!+"):-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);if(e.AQF)return Z(this,!0);if(C.test(this))return-1==this.indexOf(z)?this:this.replace(L,"+");if(j.test(this))return-1==this.indexOf(z)?"'"+this+"'":"'"+this.replace(L,"+")+"'";var n=Z(this);return 39==n.charCodeAt(0)?"%27"+n.substring(1):n}});var X=function(){function t(r,n,i,o){e(this,t),this.text=r,this.pos=this.markPos=n,this.end=i,this.options=o}return r(t,[{key:"skipAmps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.text,r=this.end,n=this.pos;if(e)for(;n<r&&t.charCodeAt(n)===q;)n++;else if(n<r&&t.charCodeAt(n)===q){for(n++;n<r&&t.charCodeAt(n)===q;n++);n!==r&&n--}this.pos=n}},{key:"structChar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){var t=this.text.charCodeAt(this.pos);switch(t){case q:case 61:if(e)return;return this.pos++,t}}var r=this.pos,n=this.ordinal();switch(n){case T:case M:if(e)return void(this.pos=r);case J:case I:return n;default:return void(this.pos=r)}}},{key:"ordinal",value:function(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}},{key:"accept",value:function(e){var t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}},{key:"acceptPlus",value:function(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}},{key:"done",value:function(){return this.end<=this.pos}},{key:"validateLiteral",value:function(e,t){for(var r=this.text,n=this.end;e<n;e++){switch(g(r.charCodeAt(e))&t){case 0:throw new SyntaxError(O(h,e));case b:return e;case 8:return e+1;default:continue}}}},{key:"findLiteralEnd",value:function(){var e=this.text,t=this.end,r=this.pos,n=39===e.charCodeAt(r);n&&r++;var i=n?28:18;if(void 0!==(r=this.validateLiteral(r,i)))return r;if(n)throw new SyntaxError(O("JSON->URL: quoted string still open",r));return t}},{key:"isEmptyObject",value:function(){if(this.options.noEmptyComposite){var e=this.pos;if(!this.accept(M))return!1;var t=this.pos,r=this.accept(I);return this.pos=r?t:e,r}return!1}},{key:"parseLiteral",value:function(e){var t=this.pos,r=this.options,n=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(n)==M),n<=t)return function(e,t){if(t)return K;throw new SyntaxError(O(v,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues);if(!0===r.impliedStringLiterals)return this.parseStringLiteral(n,!0);var i=this.parseTrueFalseNull(n,e);if(void 0!==i)return i;var o=this.parseNumberLiteral(n,e);return void 0!==o?o:this.parseStringLiteral(n,!1)}},{key:"parseDigits",value:function(e){for(var t,r=!1;this.pos<e;)switch(this.ordinal()){case _:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}},{key:"parseExponentValue",value:function(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}},{key:"parseExponent",value:function(e){var t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}},{key:"parseFraction",value:function(e){var t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}},{key:"parseInteger",value:function(e){return!(e<=this.pos)&&(!!this.accept(_)||this.parseDigits(e))}},{key:"parseNumberLiteral",value:function(e,t){var r=this.text,n=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){var i=decodeURIComponent(r.substring(n,e));return t?i:Number(i)}this.pos=n}},{key:"parseStringLiteral",value:function(e,t){var r=this.text,n=this.pos,i=t||39!==r.charCodeAt(n)?r.substring(n,e):r.substring(n+1,e-1);return i=decodeURIComponent(i.replace(k,z)),this.pos=e,i}},{key:"parseTrueFalseNull",value:function(e,t){var r,n,i,o,s,a=this.text,u=this.pos;switch(e-u){case 4:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),116===r&&114===n&&117===i&&101===o)return this.pos=e,!t||"true";if(110===r&&117===n&&108===i&&108===o)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),s=a.charCodeAt(u+4),102===r&&n===B&&108===i&&115===o&&101===s)return this.pos=e,!!t&&"false"}}},{key:"newEmptyValue",value:function(){var e=this.options;if(e.noEmptyComposite)return[];var t=e.emptyValue;return"function"==typeof t?t():t}},{key:"newNullValue",value:function(){var e=this.options,t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=K),t}}]),t}(),Y=function(t){n(o,t);var i=l(o);function o(t,r,n,s){return e(this,o),i.call(this,t,r,n,s)}return r(o,[{key:"ordinal",value:function(e){var t,r,n=e||this.pos,i=this.text.charCodeAt(n);return 37===i?(t=function(e,t,r){if(r<=t+1)throw new SyntaxError(O(m,t));return G(t,e.charCodeAt(t))<<4|G(t,e.charCodeAt(t+1))}(this.text,n+1,this.end),r=3):(t=i,r=1),void 0===e&&(this.pos+=r),t}},{key:"acceptPlus",value:function(){return this.accept(43)}},{key:"findLiteralEnd",value:function(){for(var e=this.end,t=this.pos,r=this.text,n=t;;){if(e<=this.pos)return this.pos=t,e;switch(50&g(r.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return n=this.pos,this.pos=t,n;case 0:throw new SyntaxError(O(h,n))}switch(this.ordinal()){case J:case I:case M:case T:return this.pos=t,n;case 33:if(this.pos===e)throw new SyntaxError(O(w,n));this.ordinal(),n=this.pos;break;default:n=this.pos}}}},{key:"parseStringLiteral",value:function(e){var t=this.text,r=this.pos,n=decodeURIComponent(t.substring(r,e).replace(k,z));return this.pos=e,"!e"===n?K:n.replace(U,(function(e,t,n){if(2===e.length){var i=e.charCodeAt(1),o=Q[i];if(void 0!==o)return o}throw new SyntaxError(O(w,r+n))}))}}]),o}(X),ee=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.parseDepth=0,r}return r(o,[{key:"replaceAndPush",value:function(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(O("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}},{key:"replace",value:function(e){this[this.parseDepth]=e}},{key:"depth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&(this.parseDepth--,this.pop()),this.parseDepth}}]),o}(u(Array)),te=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.numValues=0,r}return r(o,[{key:"popObjectValue",value:function(e,t){t=t||this.pop();var r=this.pop(),n=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(n[r]=t),n}},{key:"popArrayValue",value:function(e,t){t=t||this.pop();var r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}},{key:"checkValueLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(O(y,e))}},{key:"appendArrayValue",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}]),o}(u(Array));function re(e){for(;"function"==typeof e;)e=e();return e}function ne(e,t,r,n){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=re(r))instanceof S||(r=new S(r,n)),r}function ie(e,t,r,n){return n.AQF?new Y(e,t,r,n):new X(e,t,r,n)}function oe(e,t){return"number"==typeof e?e:t}function se(e,t,r,n,i){if(void 0!==e){n=ne(t,r,n,i),e=String(e);var o=oe(t,0),s=oe(r,e.length);if(s<=o){if(void 0!==n.impliedArray)return n.impliedArray;if(void 0!==n.impliedObject)return n.impliedObject;throw new SyntaxError(O("JSON->URL: expected value",0))}if(s>n.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");var a=n.wwwFormUrlEncoded&&(n.impliedObject||n.impliedArray),u=new te(n),c=new ee(n),l=ie(e,o,s,n);if(void 0!==n.impliedObject)u.push(n.impliedObject),c.push(6);else if(void 0!==n.impliedArray)u.push(n.impliedArray),c.push(2);else{if(l.structChar(!0)!==J){var y=l.parseLiteral(!1);if(l.done())return y;throw new SyntaxError(O(p,0))}c.push(1)}for(a&&l.skipAmps(!0);;){if(l.done())throw new SyntaxError(O(f,l.pos));var v=void 0,w=void 0,m=void 0;switch(c[c.depth()]){case 1:switch(l.structChar(!0)){case J:u.appendArrayValue(l.pos,[]),c.replaceAndPush(l.pos,3,1);continue;case I:if(-1===c.depth(!0)){if(l.done())return l.newEmptyValue();throw new SyntaxError(O(d,l.pos))}if(u.appendArrayValue(l.pos,l.newEmptyValue()),0===c.depth()&&(a&&l.skipAmps(),l.done())){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}continue}switch(u.checkValueLimit(l.pos),v=(w=l.isEmptyObject())?{}:l.parseLiteral(),m=l.pos,l.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case T:c.replace(2),u.appendArrayValue(m,[]),u.push(v),u.popArrayValue(n);continue;case I:switch(w?u.push({}):u.appendArrayValue(m,[v]),c.depth(!0)){case-1:if(l.pos===s)return u[0];throw new SyntaxError(O(d,m));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,m))}}continue;case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case M:c.replace(4),u.push({},v);continue;default:throw new SyntaxError(O(p,m))}case 2:if(l.accept(J)){c.replaceAndPush(l.pos,3,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedArray)return u.popArrayValue(n,v);throw new SyntaxError(O(f,s))}c.replace(3),u.push(v);continue;case 3:switch(u.popArrayValue(n),l.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case T:c.replace(2);continue;case I:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedArray)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma or close paren",l.pos));case 4:if(l.accept(J)){c.replaceAndPush(l.pos,5,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedObject)return u.popObjectValue(n,v);throw new SyntaxError(O(f,s))}c.replace(5),u.push(v);continue;case 5:switch(u.popObjectValue(n),m=l.pos,l.structChar()){case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case T:c.replace(6);continue;case I:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedObject)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(d,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma, open paren, or close paren",l.pos));case 6:if(v=l.parseLiteral(!0),a&&l.skipAmps(),l.done()){if(n.impliedObject&&0==c.depth())return u.push(v,n.getMissingValue(v)),u.popObjectValue(n);throw new SyntaxError(O(f,s))}switch(l.structChar()){case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case M:break;case q:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case T:if(n.impliedObject&&0==c.depth()){u.push(v,n.getMissingValue(v)),u.popObjectValue(n);continue}default:throw new SyntaxError(O(x,l.pos))}c.replace(4),u.push(v);continue;default:throw new SyntaxError(O("JSON->URL: internal error",l.pos))}}}}return function(){function t(r){for(e(this,t);"function"==typeof r;)r=r();void 0===r&&(r={}),this.maxParseDepth="number"==typeof r.maxParseDepth?parseInt(r.maxParseDepth):32,this.maxParseValues="number"==typeof r.maxParseValues?parseInt(r.maxParseValues):4096,this.maxParseChars="number"==typeof r.maxParseChars?parseInt(r.maxParseChars):32768,this.emptyValue=void 0===r.emptyValue?{}:r.emptyValue,this.nullValue=void 0===r.nullValue?null:r.nullValue}return r(t,[{key:"parseLiteral",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);var o=ie(e,t,r,ne(i));return o.parseLiteral(n)}},{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,this)}}],[{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,void 0)}},{key:"stringify",value:function(e,t){if(void 0!==e)return t=new V(re(t)),null===e?H(t):e.toJsonURLText(t,0)}}]),t}()})); |
@@ -235,2 +235,12 @@ | ||
maxParseValues?: number, | ||
/** | ||
* @type {boolean} [ignoreNullArrayMembers=false] Ignore null array | ||
* members. | ||
*/ | ||
ignoreNullArrayMembers?: boolean, | ||
/** | ||
* @type {boolean} [ignoreNullObjectMembers=false] Ignore null object | ||
* members. | ||
*/ | ||
ignoreNullObjectMembers?: boolean, | ||
} | ||
@@ -237,0 +247,0 @@ |
{ | ||
"name": "@jsonurl/jsonurl", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"publishConfig": { | ||
@@ -36,19 +36,19 @@ "access": "public" | ||
"devDependencies": { | ||
"@babel/cli": "^7.13.14", | ||
"@babel/core": "^7.13.15", | ||
"@babel/preset-env": "^7.13.15", | ||
"@babel/cli": "^7.15.4", | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.4", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"babel-jest": "^26.6.3", | ||
"babel-jest": "^27.1.0", | ||
"editorconfig": "^0.15.3", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-jest": "^24.3.4", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"jest": "^26.6.3", | ||
"jsdoc": "^3.6.6", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.44.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.4.0", | ||
"eslint-plugin-prettier": "^3.4.1", | ||
"jest": "^27.1.0", | ||
"jsdoc": "^3.6.7", | ||
"prettier": "^2.3.0", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-eslint": "^7.0.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.2.4" | ||
"typescript": "^4.4.2" | ||
}, | ||
@@ -55,0 +55,0 @@ "browserslist": "defaults", |
@@ -1,17 +0,20 @@ | ||
# JSON→URL | ||
# JSON→URL | ||
[][license] | ||
[](https://www.npmjs.com/package/@jsonurl/jsonurl) | ||
 | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://github.com/jsonurl/jsonurl-js/actions/workflows/ci.yml) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://sonarcloud.io/dashboard?id=jsonurl-js) | ||
[](https://snyk.io/test/github/jsonurl/jsonurl-js?targetFile=package.json) | ||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fjsonurl%2Fjsonurl-js?ref=badge_shield) | ||
[](CODE_OF_CONDUCT.md) | ||
[](CONTRIBUTING.md) | ||
[](https://jsonurl.zulipchat.com/) | ||
## About | ||
[RFC8259][RFC8259] describes the JSON data model and interchange format, which is widely | ||
@@ -21,10 +24,12 @@ used in application-level protocols including RESTful APIs. It is common for | ||
However, POST is suboptimal for requests which do not modify a resource's | ||
state. JSON→URL defines a text format for the JSON data model suitable | ||
state. JSON→URL defines a text format for the JSON data model suitable | ||
for use within a [URL][RFC1738]/[URI][RFC3986]. | ||
## Usage | ||
JSON→URL is available as a commonjs module (suitable for use in Node), ES6 | ||
JSON→URL is available as a commonjs module (suitable for use in Node), ES6 | ||
module, or a script that may be used directly in a browser. | ||
### NPM install | ||
```sh | ||
@@ -35,14 +40,19 @@ npm install @jsonurl/jsonurl --save | ||
### CJS | ||
```js | ||
const JsonURL = require("@jsonurl/jsonurl"); | ||
``` | ||
### ES6 (Node + Babel) | ||
```js | ||
import JsonURL from "@jsonurl/jsonurl"; | ||
``` | ||
### Browser script tag | ||
```html | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/@jsonurl/jsonurl@1.1.2" | ||
integrity="sha384-kjdLAXTSwonl867FqmglObjdk+qIgyew1EE+3wCpYsJOthDuugo4/9xKHPjicfDL" | ||
src="https://cdn.jsdelivr.net/npm/@jsonurl/jsonurl@1.1.5" | ||
integrity="sha512-PgDMK2pu/5iHU+sUvfCWIKugVg2NLSN1jmQJyJKbQw1MZAMvrU7XX3fPv4FJXgGBxTCsDnjhMmlZK5pzgPndTQ==" | ||
crossorigin="anonymous"></script> | ||
@@ -52,3 +62,7 @@ ``` | ||
### The JavaScript API | ||
Once included, the API is the same for all three. | ||
[][runkit1] | ||
```js | ||
@@ -58,19 +72,38 @@ let value = JsonURL.parse( "(Hello:World!)" ); | ||
``` | ||
There are options available, but that's all you need to get started. | ||
JSON→URL has no runtime dependencies. | ||
If you intend to use JSON→URL inside a browser's address bar then you'll want to | ||
enable the AQF (address bar query string friendly) syntax. | ||
[][runkit2] | ||
```js | ||
let value = JsonURL.parse( "(Hello:Address Bar!!)", { AQF: true }); | ||
let string = JsonURL.stringify( value, { AQF: true } ); | ||
``` | ||
There are additional options available, but that's all you need to get started. | ||
JSON→URL has no runtime dependencies. | ||
## Security | ||
The parser is designed to parse untrusted input. It supports limits on | ||
the number of parsed values and depth of nested arrays or objects. | ||
When the limit is exceeded an Error is thrown, and sane limit values are | ||
When the limit is exceeded an Error is thrown, and reasonable limit values are | ||
set by default. | ||
[RFC8259]: https://tools.ietf.org/html/rfc8259 | ||
[RFC3986]: https://tools.ietf.org/html/rfc3986 | ||
[RFC1738]: https://tools.ietf.org/html/rfc1738 | ||
[license]: https://opensource.org/licenses/MIT | ||
[runkit1]: https://runkit.com/jsonurl/hello-world | ||
[runkit2]: https://runkit.com/jsonurl/hello-aqf | ||
## License | ||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fjsonurl%2Fjsonurl-js?ref=badge_large) |
@@ -9,4 +9,4 @@ # Security Policy | ||
| ------- | ------------------ | | ||
| 1.1.2 | :white_check_mark: | | ||
| < 1.1.2 | :x: | | ||
| 1.1.5 | :white_check_mark: | | ||
| < 1.1.5 | :x: | | ||
@@ -18,3 +18,3 @@ ## Reporting a Vulnerability | ||
If you beleive you've found a vulnerability or other security related issue | ||
please email a complete description to jsonurl.org ``at'' gmail.com. | ||
please email a complete description to jsonurl.org \`\`at'' gmail.com. | ||
If the issue is accepted a discussion will begin on a private | ||
@@ -25,3 +25,3 @@ [Zulip][zulip] channel, and you mabe be invited to participate. Once a fix | ||
If the vulnerability is declined a Github issue may still be created, | ||
If the vulnerability is declined a Github issue may still be created, | ||
and/or the Zulip channel may be made public, to make the discussion public | ||
@@ -28,0 +28,0 @@ if the repository owners see value in that. Otherwise, we appreciate your |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
213067
2.05%4840
0.98%106
45.21%11
-8.33%