@tanstack/react-location-jsurl
Version:
See https://react-location.tanstack.com/tools/jsurl
13 lines (12 loc) • 2.37 kB
JavaScript
/**
* react-location-jsurl
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tanstack/react-location")):"function"==typeof define&&define.amd?define(["exports","@tanstack/react-location"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).ReactLocationJsurl={},r.ReactLocation)}(this,(function(r,e){"use strict";var t=["'"],n="-";function i(r){function e(r){return/[^\w-.]/.test(r)?r.replace(/[^\w-.]/g,(function(r){return"$"===r?"!":(r=r.charCodeAt(0))<256?"*"+("00"+r.toString(16)).slice(-2):"**"+("0000"+r.toString(16)).slice(-4)})):r}var t;switch(typeof r){case"number":return isFinite(r)?"~"+r:"~null";case"boolean":return"~"+r;case"string":return"~"+n+e(r);case"object":if(!r)return"~null";if(t=[],Array.isArray(r)){for(var a=0;a<r.length;a++)t[a]=i(r[a])||"~null";return"~("+(t.join("")||"~")+")"}for(var o in r)if(r.hasOwnProperty(o)){var s=i(r[o]);s&&t.push(e(o)+s)}return"~("+t.join("~")+")";default:return""}}var a={true:!0,false:!1,null:null};function o(r){if(!r)return r;r=r.replace(/%(25)*27/g,"'");var e=0,i=r.length;function o(t){if(r.charAt(e)!==t)throw new Error;e++}function s(){for(var t,n=e,a="";e<i&&"~"!==(t=r.charAt(e))&&")"!==t;)switch(t){case"*":n<e&&(a+=r.substring(n,e)),"*"===r.charAt(e+1)?(a+=String.fromCharCode(parseInt(r.substring(e+2,e+6),16)),n=e+=6):(a+=String.fromCharCode(parseInt(r.substring(e+1,e+3),16)),n=e+=3);break;case"!":n<e&&(a+=r.substring(n,e)),a+="$",n=++e;break;default:e++}return a+r.substring(n,e)}return function c(){var u,f,l;o("~");var h=f=r.charAt(e);if("("===h){if(e++,"~"===r.charAt(e))if(u=[],")"===r.charAt(e+1))e++;else do{u.push(c())}while("~"===r.charAt(e));else if(u={},")"!==r.charAt(e))do{u[s()]=c()}while("~"===r.charAt(e)&&++e);o(")")}else if([n].concat(t).includes(h))e++,u=s();else{for(l=e++;e<i&&/[^)~]/.test(r.charAt(e));)e++;var d=r.substring(l,e);if(/[\d\-]/.test(f))u=parseFloat(d);else if(void 0===(u=a[d]))throw new Error}return u}()}r.parseSearch=function(r){return e.parseSearchWith(o)(r)},r.stringifySearch=function(r){return e.stringifySearchWith(i)(r)},Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.min.js.map