@stoplight/path
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,1 +0,1 @@ | ||
"use strict";function format(e){let r="";return e.absolute&&("file"===e.protocol?(e.drive&&(r+=e.drive),r+="/"):(r+=e.protocol+"://",e.origin&&(r+=e.origin+"/"))),""===(r+=e.path.join("/"))&&(r="."),r}function peg$subclass(e,r){function t(){this.constructor=e}t.prototype=r.prototype,e.prototype=new t}function peg$SyntaxError(e,r,t,n){this.message=e,this.expected=r,this.found=t,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(e,r){r=void 0!==r?r:{};var t,n,a,o,s={},i={Path:0},u=0,l=[function(e,r,t,n){return{protocol:e,origin:r,absolute:!0,...t,...n}},function(e,r,t){return{protocol:e,origin:r,absolute:!0,...t,path:[]}},"http://",m("http://",!0),function(e){return"http"},"https://",m("https://",!0),function(e){return"https"},"",function(){return null},function(e,r,t){return{protocol:e,origin:null,absolute:!0,...r,...t}},"file://",m("file://",!0),"file:",m("file:",!0),function(e){return"file"},function(e,r){return{protocol:"file",origin:null,absolute:!0,...e,...r}},function(){return{drive:null}},/^[A-Za-z]/,d([["A","Z"],["a","z"]],!1,!1),":",m(":",!1),function(e){return{drive:e.toLowerCase()+":"}},function(){return{drive:null}},function(e){return{protocol:null,origin:null,absolute:!1,drive:null,...e}},function(e){return{path:e}},function(e,r){return[e,...r]},function(e){return[e]},".",m(".",!1),"/",m("/",!1),"\\",m("\\",!1),/^[^\/\\]/,d(["/","\\"],!0,!1)],p=[k(";!./ &;&.) &;(.# &;-"),k("%;\"/F#;%/=$;*/4$;./+$8$: $$#\"! )($'#(#'#(\"'#&'#.F &%;\"/<#;%/3$;,/*$8#:!##\"! )(#'#(\"'#&'#"),k(";#.# &;$"),k('%3"""5\'7#/\' 8!:$!! )'),k("%3%\"\"5(7&/' 8!:'!! )"),k('%$;5/�#*;5&&&#/"!&,).. &% (/& 8!:)! )'),k("%;'/<#;)/3$;./*$8#:*##\"! )(#'#(\"'#&'#"),k('%3+""5\'7,.) &3-""5%7./\' 8!:/!! )'),k('%;)/2#;./)$8":0""! )("\'#&\'#'),k(";*.# &;+"),k("%;4/& 8!:1! )"),k('%42""5!73/@#24""6475/1$;4/($8#:6#!")(#\'#("\'#&\'#'),k("% (/& 8!:7! )"),k('%;0/1#;./($8":8"! )("\'#&\'#'),k("%;//' 8!:9!! )"),k("%;1/;#;4/2$;//)$8#::#\"\" )(#'#(\"'#&'#./ &%;1/' 8!:;!! )"),k(";2.# &;3"),k('%$;5/�#*;5&&&#/"!&,).# & ('),k('%2<""6<7=/,#;4/#$+")("\'#&\'#'),k(" ("),k('2>""6>7?.) &2@""6@7A'),k('4B""5!7C')],c=0,h=[{line:1,column:1}],f=0,g=[],b=0;if("startRule"in r){if(!(r.startRule in i))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=i[r.startRule]}function m(e,r){return{type:"literal",text:e,ignoreCase:r}}function d(e,r,t){return{type:"class",parts:e,inverted:r,ignoreCase:t}}function x(r){var t,n=h[r];if(n)return n;for(t=r-1;!h[t];)t--;for(n={line:(n=h[t]).line,column:n.column};t<r;)10===e.charCodeAt(t)?(n.line++,n.column=1):n.column++,t++;return h[r]=n,n}function $(e,r){var t=x(e),n=x(r);return{start:{offset:e,line:t.line,column:t.column},end:{offset:r,line:n.line,column:n.column}}}function v(e){c<f||(c>f&&(f=c,g=[]),g.push(e))}function k(e){var r,t=new Array(e.length);for(r=0;r<e.length;r++)t[r]=e.charCodeAt(r)-32;return t}if((t=function r(t){for(var n,a,o=p[t],i=0,u=[],h=o.length,f=[],g=[];;){for(;i<h;)switch(o[i]){case 0:g.push(l[o[i+1]]),i+=2;break;case 1:g.push(void 0),i++;break;case 2:g.push(null),i++;break;case 3:g.push(s),i++;break;case 4:g.push([]),i++;break;case 5:g.push(c),i++;break;case 6:g.pop(),i++;break;case 7:c=g.pop(),i++;break;case 8:g.length-=o[i+1],i+=2;break;case 9:g.splice(-2,1),i++;break;case 10:g[g.length-2].push(g.pop()),i++;break;case 11:g.push(g.splice(g.length-o[i+1],o[i+1])),i+=2;break;case 12:g.push(e.substring(g.pop(),c)),i++;break;case 13:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 14:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]===s?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 15:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]!==s?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 16:g[g.length-1]!==s?(f.push(h),u.push(i),h=i+2+o[i+1],i+=2):i+=2+o[i+1];break;case 17:f.push(h),u.push(i+3+o[i+1]+o[i+2]),e.length>c?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 18:f.push(h),u.push(i+4+o[i+2]+o[i+3]),e.substr(c,l[o[i+1]].length)===l[o[i+1]]?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 19:f.push(h),u.push(i+4+o[i+2]+o[i+3]),e.substr(c,l[o[i+1]].length).toLowerCase()===l[o[i+1]]?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 20:f.push(h),u.push(i+4+o[i+2]+o[i+3]),l[o[i+1]].test(e.charAt(c))?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 21:g.push(e.substr(c,o[i+1])),c+=o[i+1],i+=2;break;case 22:g.push(l[o[i+1]]),c+=l[o[i+1]].length,i+=2;break;case 23:g.push(s),0===b&&v(l[o[i+1]]),i+=2;break;case 24:g[g.length-1-o[i+1]],i+=2;break;case 25:c,i++;break;case 26:for(n=o.slice(i+4,i+4+o[i+3]),a=0;a<o[i+3];a++)n[a]=g[g.length-1-n[a]];g.splice(g.length-o[i+2],o[i+2],l[o[i+1]].apply(null,n)),i+=4+o[i+3];break;case 27:g.push(r(o[i+1])),i+=2;break;case 28:b++,i++;break;case 29:b--,i++;break;default:throw new Error("Invalid opcode: "+o[i]+".")}if(!(f.length>0))break;h=f.pop(),i=u.pop()}return g[0]}(u))!==s&&c===e.length)return t;throw t!==s&&c<e.length&&v({type:"end"}),n=g,a=f<e.length?e.charAt(f):null,o=f<e.length?$(f,f+1):$(f,f),new peg$SyntaxError(peg$SyntaxError.buildMessage(n,a),n,a,o)}Object.defineProperty(exports,"__esModule",{value:!0}),peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(e,r){var t={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var r,t="";for(r=0;r<e.parts.length;r++)t+=e.parts[r]instanceof Array?o(e.parts[r][0])+"-"+o(e.parts[r][1]):o(e.parts[r]);return"["+(e.inverted?"^":"")+t+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}return"Expected "+function(e){var r,n,a,o=new Array(e.length);for(r=0;r<e.length;r++)o[r]=(a=e[r],t[a.type](a));if(o.sort(),o.length>0){for(r=1,n=1;r<o.length;r++)o[r-1]!==o[r]&&(o[n]=o[r],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(r)+" found."};var grammar={SyntaxError:peg$SyntaxError,parse:peg$parse},grammar_1=grammar.parse;function parse(e){if("string"!=typeof e)throw new Error(`@stoplight/path: Cannot parse ${e} because it is not a string`);return grammar_1(e,{})}function normalize(e){return format(normalizeParsed(parse(e)))}function normalizeParsed(e){let r=e.path;r=r.filter(e=>""!==e&&"."!==e);const t=[];for(const n of r)".."===n&&t.length&&".."!==t[t.length-1]?t.pop():".."===n&&e.absolute||t.push(n);return e.path=t,e}function parseBase(e){let r=e.lastIndexOf(".");".."===e&&(r=-1),"."===e&&(r=-1);let t=e,n="";return r>0&&(t=e.slice(0,r),n=e.slice(r)),{name:t,ext:n}}const basename=(e,r)=>{const t=normalizeParsed(parse(e)).path.pop();if(!t)return"";const{name:n,ext:a}=parseBase(t);return!0===r||r===a?n:`${n}${a}`},dirname=e=>{const r=normalizeParsed(parse(e));return r.path.pop(),format(normalizeParsed(r))},extname=e=>{const r=normalizeParsed(parse(e)).path.pop();if(!r)return"";const{ext:t}=parseBase(r);return t};function isAbsolute(e){return parse(e).absolute}function isURL(e){const r=parse(e);return"http"===r.protocol||"https"===r.protocol}const join=(...e)=>{if(0===e.length)return".";const r=e.map(parse),t=Object.assign({},r[0]);for(let n=1;n<r.length;n++){const a=r[n];if(a.absolute)throw new Error('Cannot join an absolute path "'+e[n]+'" in the middle of other paths.');for(const e of a.path)t.path.push(e)}return format(normalizeParsed(t))};function relative(e,r){const t=normalizeParsed(parse(r));if(!t.absolute)return format(t);const n=normalizeParsed(parse(e));if(t.origin!==n.origin)return format(t);if(!n.absolute)return format(t);if(n.drive!==t.drive)return format(t);const a=Math.min(n.path.length,t.path.length);for(let e=0;e<a&&n.path[0]===t.path[0];e++)n.path.shift(),t.path.shift();return t.path.unshift(...n.path.fill("..")),format({origin:null,drive:null,absolute:!1,protocol:null,path:t.path})}function resolve(...e){if(0===e.length)return".";const r=normalizeParsed(parse(e[e.length-1]));return r.absolute?format(r):join(...e)}const sep="/",startsWithWindowsDrive=e=>{return null!==parse(e).drive};function deserializeSrn(e){const[r,t,n,...a]=e.split("/"),o=a.length?`/${a.join("/")}`:void 0;let s,i;return o&&(i=extname(o),s=basename(o)),{shortcode:r,orgSlug:t,projectSlug:n,uri:o,file:s,ext:i}}function serializeSrn({shortcode:e,orgSlug:r,projectSlug:t,uri:n=""}){return[e,r,t,n.replace(/^\//,"")].filter(Boolean).join("/")}exports.basename=basename,exports.deserializeSrn=deserializeSrn,exports.dirname=dirname,exports.extname=extname,exports.format=format,exports.isAbsolute=isAbsolute,exports.isURL=isURL,exports.join=join,exports.normalize=normalize,exports.parse=parse,exports.relative=relative,exports.resolve=resolve,exports.sep="/",exports.serializeSrn=serializeSrn,exports.startsWithWindowsDrive=startsWithWindowsDrive,exports.toFSPath=normalize; | ||
"use strict";function format(e){let r="";return e.absolute&&("file"===e.protocol?(e.drive&&(r+=e.drive),r+="/"):(r+=e.protocol+"://",e.origin&&(r+=e.origin+"/"))),""===(r+=e.path.join("/"))&&(r="."),r}function peg$subclass(e,r){function t(){this.constructor=e}t.prototype=r.prototype,e.prototype=new t}function peg$SyntaxError(e,r,t,n){this.message=e,this.expected=r,this.found=t,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(e,r){r=void 0!==r?r:{};var t,n,a,o,s={},i={Path:0},u=0,l=[function(e,r,t,n){return{protocol:e,origin:r,absolute:!0,...t,...n}},function(e,r,t){return{protocol:e,origin:r,absolute:!0,...t,path:[]}},"http://",d("http://",!0),function(e){return"http"},"https://",d("https://",!0),function(e){return"https"},"",function(){return null},function(e,r,t){return{protocol:e,origin:null,absolute:!0,...r,...t}},"file://",d("file://",!0),"file:",d("file:",!0),function(e){return"file"},function(e,r){return{protocol:"file",origin:null,absolute:!0,...e,...r}},function(){return{drive:null}},/^[A-Za-z]/,m([["A","Z"],["a","z"]],!1,!1),":",d(":",!1),function(e){return{drive:e.toLowerCase()+":"}},function(){return{drive:null}},function(e){return{protocol:null,origin:null,absolute:!1,drive:null,...e}},function(e){return{path:e}},function(e,r){return[e,...r]},function(e){return[e]},".",d(".",!1),"/",d("/",!1),"\\",d("\\",!1),/^[^\/\\]/,m(["/","\\"],!0,!1)],p=[k(";!./ &;&.) &;(.# &;-"),k("%;\"/F#;%/=$;*/4$;./+$8$: $$#\"! )($'#(#'#(\"'#&'#.F &%;\"/<#;%/3$;,/*$8#:!##\"! )(#'#(\"'#&'#"),k(";#.# &;$"),k('%3"""5\'7#/\' 8!:$!! )'),k("%3%\"\"5(7&/' 8!:'!! )"),k('%$;5/�#*;5&&&#/"!&,).. &% (/& 8!:)! )'),k("%;'/<#;)/3$;./*$8#:*##\"! )(#'#(\"'#&'#"),k('%3+""5\'7,.) &3-""5%7./\' 8!:/!! )'),k('%;)/2#;./)$8":0""! )("\'#&\'#'),k(";*.# &;+"),k("%;4/& 8!:1! )"),k('%42""5!73/@#24""6475/1$;4/($8#:6#!")(#\'#("\'#&\'#'),k("% (/& 8!:7! )"),k('%;0/1#;./($8":8"! )("\'#&\'#'),k("%;//' 8!:9!! )"),k("%;1/;#;4/2$;//)$8#::#\"\" )(#'#(\"'#&'#./ &%;1/' 8!:;!! )"),k(";2.# &;3"),k('%$;5/�#*;5&&&#/"!&,).# & ('),k('%2<""6<7=/,#;4/#$+")("\'#&\'#'),k(" ("),k('2>""6>7?.) &2@""6@7A'),k('4B""5!7C')],c=0,h=[{line:1,column:1}],f=0,g=[],b=0;if("startRule"in r){if(!(r.startRule in i))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=i[r.startRule]}function d(e,r){return{type:"literal",text:e,ignoreCase:r}}function m(e,r,t){return{type:"class",parts:e,inverted:r,ignoreCase:t}}function x(r){var t,n=h[r];if(n)return n;for(t=r-1;!h[t];)t--;for(n={line:(n=h[t]).line,column:n.column};t<r;)10===e.charCodeAt(t)?(n.line++,n.column=1):n.column++,t++;return h[r]=n,n}function $(e,r){var t=x(e),n=x(r);return{start:{offset:e,line:t.line,column:t.column},end:{offset:r,line:n.line,column:n.column}}}function v(e){c<f||(c>f&&(f=c,g=[]),g.push(e))}function k(e){var r,t=new Array(e.length);for(r=0;r<e.length;r++)t[r]=e.charCodeAt(r)-32;return t}if((t=function r(t){for(var n,a,o=p[t],i=0,u=[],h=o.length,f=[],g=[];;){for(;i<h;)switch(o[i]){case 0:g.push(l[o[i+1]]),i+=2;break;case 1:g.push(void 0),i++;break;case 2:g.push(null),i++;break;case 3:g.push(s),i++;break;case 4:g.push([]),i++;break;case 5:g.push(c),i++;break;case 6:g.pop(),i++;break;case 7:c=g.pop(),i++;break;case 8:g.length-=o[i+1],i+=2;break;case 9:g.splice(-2,1),i++;break;case 10:g[g.length-2].push(g.pop()),i++;break;case 11:g.push(g.splice(g.length-o[i+1],o[i+1])),i+=2;break;case 12:g.push(e.substring(g.pop(),c)),i++;break;case 13:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 14:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]===s?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 15:f.push(h),u.push(i+3+o[i+1]+o[i+2]),g[g.length-1]!==s?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 16:g[g.length-1]!==s?(f.push(h),u.push(i),h=i+2+o[i+1],i+=2):i+=2+o[i+1];break;case 17:f.push(h),u.push(i+3+o[i+1]+o[i+2]),e.length>c?(h=i+3+o[i+1],i+=3):(h=i+3+o[i+1]+o[i+2],i+=3+o[i+1]);break;case 18:f.push(h),u.push(i+4+o[i+2]+o[i+3]),e.substr(c,l[o[i+1]].length)===l[o[i+1]]?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 19:f.push(h),u.push(i+4+o[i+2]+o[i+3]),e.substr(c,l[o[i+1]].length).toLowerCase()===l[o[i+1]]?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 20:f.push(h),u.push(i+4+o[i+2]+o[i+3]),l[o[i+1]].test(e.charAt(c))?(h=i+4+o[i+2],i+=4):(h=i+4+o[i+2]+o[i+3],i+=4+o[i+2]);break;case 21:g.push(e.substr(c,o[i+1])),c+=o[i+1],i+=2;break;case 22:g.push(l[o[i+1]]),c+=l[o[i+1]].length,i+=2;break;case 23:g.push(s),0===b&&v(l[o[i+1]]),i+=2;break;case 24:g[g.length-1-o[i+1]],i+=2;break;case 25:c,i++;break;case 26:for(n=o.slice(i+4,i+4+o[i+3]),a=0;a<o[i+3];a++)n[a]=g[g.length-1-n[a]];g.splice(g.length-o[i+2],o[i+2],l[o[i+1]].apply(null,n)),i+=4+o[i+3];break;case 27:g.push(r(o[i+1])),i+=2;break;case 28:b++,i++;break;case 29:b--,i++;break;default:throw new Error("Invalid opcode: "+o[i]+".")}if(!(f.length>0))break;h=f.pop(),i=u.pop()}return g[0]}(u))!==s&&c===e.length)return t;throw t!==s&&c<e.length&&v({type:"end"}),n=g,a=f<e.length?e.charAt(f):null,o=f<e.length?$(f,f+1):$(f,f),new peg$SyntaxError(peg$SyntaxError.buildMessage(n,a),n,a,o)}Object.defineProperty(exports,"__esModule",{value:!0}),peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(e,r){var t={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var r,t="";for(r=0;r<e.parts.length;r++)t+=e.parts[r]instanceof Array?o(e.parts[r][0])+"-"+o(e.parts[r][1]):o(e.parts[r]);return"["+(e.inverted?"^":"")+t+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}return"Expected "+function(e){var r,n,a,o=new Array(e.length);for(r=0;r<e.length;r++)o[r]=(a=e[r],t[a.type](a));if(o.sort(),o.length>0){for(r=1,n=1;r<o.length;r++)o[r-1]!==o[r]&&(o[n]=o[r],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(r)+" found."};var grammar={SyntaxError:peg$SyntaxError,parse:peg$parse},grammar_1=grammar.parse;function parse(e){if("string"!=typeof e)throw new Error(`@stoplight/path: Cannot parse ${e} because it is not a string`);return grammar_1(e,{})}function normalize(e){return format(normalizeParsed(parse(e)))}function normalizeParsed(e){let r=e.path;r=r.filter(e=>""!==e&&"."!==e);const t=[];for(const n of r)".."===n&&t.length&&".."!==t[t.length-1]?t.pop():".."===n&&e.absolute||t.push(n);return e.path=t,e}function parseBase(e){let r=e.lastIndexOf(".");".."===e&&(r=-1),"."===e&&(r=-1);let t=e,n="";return r>0&&(t=e.slice(0,r),n=e.slice(r)),{name:t,ext:n}}const basename=(e,r)=>{const t=normalizeParsed(parse(e)).path.pop();if(!t)return"";const{name:n,ext:a}=parseBase(t);return!0===r||r===a?n:`${n}${a}`},dirname=e=>{const r=normalizeParsed(parse(e));return r.path.pop(),format(normalizeParsed(r))},extname=e=>{const r=normalizeParsed(parse(e)).path.pop();if(!r)return"";const{ext:t}=parseBase(r);return t};function isAbsolute(e){return parse(e).absolute}function isURL(e){const r=parse(e);return"http"===r.protocol||"https"===r.protocol}const join=(...e)=>{if(0===e.length)return".";const r=e.map(parse),t=Object.assign({},r[0]);for(let n=1;n<r.length;n++){const a=r[n];if(a.absolute)throw new Error('Cannot join an absolute path "'+e[n]+'" in the middle of other paths.');for(const e of a.path)t.path.push(e)}return format(normalizeParsed(t))};function relative(e,r){const t=normalizeParsed(parse(r));if(!t.absolute)return format(t);const n=normalizeParsed(parse(e));if(t.origin!==n.origin)return format(t);if(!n.absolute)return format(t);if(n.drive!==t.drive)return format(t);const a=Math.min(n.path.length,t.path.length);for(let e=0;e<a&&n.path[0]===t.path[0];e++)n.path.shift(),t.path.shift();return t.path.unshift(...n.path.fill("..")),format({origin:null,drive:null,absolute:!1,protocol:null,path:t.path})}function resolve(...e){if(0===e.length)return".";const r=normalizeParsed(parse(e[e.length-1]));return r.absolute?format(r):join(...e)}const sep="/",startsWithWindowsDrive=e=>{return null!==parse(e).drive};function deserializeSrn(e){const[r,t,n,...a]=e.split("/"),o=a.length?`/${a.join("/")}`:void 0;let s,i;return o&&(s=a.find(e=>e.includes(".")))&&(i=parseBase(s).ext),{shortcode:r,orgSlug:t,projectSlug:n,uri:o,file:s,ext:i}}function serializeSrn({shortcode:e,orgSlug:r,projectSlug:t,uri:n=""}){return[e,r,t,n.replace(/^\//,"")].filter(Boolean).join("/")}exports.basename=basename,exports.deserializeSrn=deserializeSrn,exports.dirname=dirname,exports.extname=extname,exports.format=format,exports.isAbsolute=isAbsolute,exports.isURL=isURL,exports.join=join,exports.normalize=normalize,exports.parse=parse,exports.relative=relative,exports.resolve=resolve,exports.sep="/",exports.serializeSrn=serializeSrn,exports.startsWithWindowsDrive=startsWithWindowsDrive,exports.toFSPath=normalize; |
@@ -1,1 +0,1 @@ | ||
function t(t){let e="";return t.absolute&&("file"===t.protocol?(t.drive&&(e+=t.drive),e+="/"):(e+=t.protocol+"://",t.origin&&(e+=t.origin+"/"))),""===(e+=t.path.join("/"))&&(e="."),e}function e(t,r,n,o){this.message=t,this.expected=r,this.found=n,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}!function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(e,Error),e.buildMessage=function(t,e){var r={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?u(t.parts[e][0])+"-"+u(t.parts[e][1]):u(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function o(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}return"Expected "+function(t){var e,n,o,u=new Array(t.length);for(e=0;e<t.length;e++)u[e]=(o=t[e],r[o.type](o));if(u.sort(),u.length>0){for(e=1,n=1;e<u.length;e++)u[e-1]!==u[e]&&(u[n]=u[e],n++);u.length=n}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."};var r=function(t,r){r=void 0!==r?r:{};var n,o,u,a,l={},c={Path:0},i=0,s=[function(t,e,r,n){return{protocol:t,origin:e,absolute:!0,...r,...n}},function(t,e,r){return{protocol:t,origin:e,absolute:!0,...r,path:[]}},"http://",k("http://",!0),function(t){return"http"},"https://",k("https://",!0),function(t){return"https"},"",function(){return null},function(t,e,r){return{protocol:t,origin:null,absolute:!0,...e,...r}},"file://",k("file://",!0),"file:",k("file:",!0),function(t){return"file"},function(t,e){return{protocol:"file",origin:null,absolute:!0,...t,...e}},function(){return{drive:null}},/^[A-Za-z]/,x([["A","Z"],["a","z"]],!1,!1),":",k(":",!1),function(t){return{drive:t.toLowerCase()+":"}},function(){return{drive:null}},function(t){return{protocol:null,origin:null,absolute:!1,drive:null,...t}},function(t){return{path:t}},function(t,e){return[t,...e]},function(t){return[t]},".",k(".",!1),"/",k("/",!1),"\\",k("\\",!1),/^[^\/\\]/,x(["/","\\"],!0,!1)],p=[w(";!./ &;&.) &;(.# &;-"),w("%;\"/F#;%/=$;*/4$;./+$8$: $$#\"! )($'#(#'#(\"'#&'#.F &%;\"/<#;%/3$;,/*$8#:!##\"! )(#'#(\"'#&'#"),w(";#.# &;$"),w('%3"""5\'7#/\' 8!:$!! )'),w("%3%\"\"5(7&/' 8!:'!! )"),w('%$;5/�#*;5&&&#/"!&,).. &% (/& 8!:)! )'),w("%;'/<#;)/3$;./*$8#:*##\"! )(#'#(\"'#&'#"),w('%3+""5\'7,.) &3-""5%7./\' 8!:/!! )'),w('%;)/2#;./)$8":0""! )("\'#&\'#'),w(";*.# &;+"),w("%;4/& 8!:1! )"),w('%42""5!73/@#24""6475/1$;4/($8#:6#!")(#\'#("\'#&\'#'),w("% (/& 8!:7! )"),w('%;0/1#;./($8":8"! )("\'#&\'#'),w("%;//' 8!:9!! )"),w("%;1/;#;4/2$;//)$8#::#\"\" )(#'#(\"'#&'#./ &%;1/' 8!:;!! )"),w(";2.# &;3"),w('%$;5/�#*;5&&&#/"!&,).# & ('),w('%2<""6<7=/,#;4/#$+")("\'#&\'#'),w(" ("),w('2>""6>7?.) &2@""6@7A'),w('4B""5!7C')],h=0,f=[{line:1,column:1}],g=0,b=[],d=0;if("startRule"in r){if(!(r.startRule in c))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=c[r.startRule]}function k(t,e){return{type:"literal",text:t,ignoreCase:e}}function x(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function $(e){var r,n=f[e];if(n)return n;for(r=e-1;!f[r];)r--;for(n={line:(n=f[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return f[e]=n,n}function v(t,e){var r=$(t),n=$(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:n.line,column:n.column}}}function m(t){h<g||(h>g&&(g=h,b=[]),b.push(t))}function w(t){var e,r=new Array(t.length);for(e=0;e<t.length;e++)r[e]=t.charCodeAt(e)-32;return r}if((n=function e(r){for(var n,o,u=p[r],a=0,c=[],i=u.length,f=[],g=[];;){for(;a<i;)switch(u[a]){case 0:g.push(s[u[a+1]]),a+=2;break;case 1:g.push(void 0),a++;break;case 2:g.push(null),a++;break;case 3:g.push(l),a++;break;case 4:g.push([]),a++;break;case 5:g.push(h),a++;break;case 6:g.pop(),a++;break;case 7:h=g.pop(),a++;break;case 8:g.length-=u[a+1],a+=2;break;case 9:g.splice(-2,1),a++;break;case 10:g[g.length-2].push(g.pop()),a++;break;case 11:g.push(g.splice(g.length-u[a+1],u[a+1])),a+=2;break;case 12:g.push(t.substring(g.pop(),h)),a++;break;case 13:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 14:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]===l?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 15:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]!==l?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 16:g[g.length-1]!==l?(f.push(i),c.push(a),i=a+2+u[a+1],a+=2):a+=2+u[a+1];break;case 17:f.push(i),c.push(a+3+u[a+1]+u[a+2]),t.length>h?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 18:f.push(i),c.push(a+4+u[a+2]+u[a+3]),t.substr(h,s[u[a+1]].length)===s[u[a+1]]?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 19:f.push(i),c.push(a+4+u[a+2]+u[a+3]),t.substr(h,s[u[a+1]].length).toLowerCase()===s[u[a+1]]?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 20:f.push(i),c.push(a+4+u[a+2]+u[a+3]),s[u[a+1]].test(t.charAt(h))?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 21:g.push(t.substr(h,u[a+1])),h+=u[a+1],a+=2;break;case 22:g.push(s[u[a+1]]),h+=s[u[a+1]].length,a+=2;break;case 23:g.push(l),0===d&&m(s[u[a+1]]),a+=2;break;case 24:g[g.length-1-u[a+1]],a+=2;break;case 25:a++;break;case 26:for(n=u.slice(a+4,a+4+u[a+3]),o=0;o<u[a+3];o++)n[o]=g[g.length-1-n[o]];g.splice(g.length-u[a+2],u[a+2],s[u[a+1]].apply(null,n)),a+=4+u[a+3];break;case 27:g.push(e(u[a+1])),a+=2;break;case 28:d++,a++;break;case 29:d--,a++;break;default:throw new Error("Invalid opcode: "+u[a]+".")}if(!(f.length>0))break;i=f.pop(),a=c.pop()}return g[0]}(i))!==l&&h===t.length)return n;throw n!==l&&h<t.length&&m({type:"end"}),o=b,u=g<t.length?t.charAt(g):null,a=g<t.length?v(g,g+1):v(g,g),new e(e.buildMessage(o,u),o,u,a)};function n(t){if("string"!=typeof t)throw new Error(`@stoplight/path: Cannot parse ${t} because it is not a string`);return r(t,{})}function o(e){return t(u(n(e)))}function u(t){let e=t.path;e=e.filter(t=>""!==t&&"."!==t);const r=[];for(const n of e)".."===n&&r.length&&".."!==r[r.length-1]?r.pop():".."===n&&t.absolute||r.push(n);return t.path=r,t}function a(t){let e=t.lastIndexOf(".");".."===t&&(e=-1),"."===t&&(e=-1);let r=t,n="";return e>0&&(r=t.slice(0,e),n=t.slice(e)),{name:r,ext:n}}const l=(t,e)=>{const r=u(n(t)).path.pop();if(!r)return"";const{name:o,ext:l}=a(r);return!0===e||e===l?o:`${o}${l}`},c=e=>{const r=u(n(e));return r.path.pop(),t(u(r))},i=t=>{const e=u(n(t)).path.pop();if(!e)return"";const{ext:r}=a(e);return r};function s(t){return n(t).absolute}function p(t){const e=n(t);return"http"===e.protocol||"https"===e.protocol}const h=(...e)=>{if(0===e.length)return".";const r=e.map(n),o=Object.assign({},r[0]);for(let t=1;t<r.length;t++){const n=r[t];if(n.absolute)throw new Error('Cannot join an absolute path "'+e[t]+'" in the middle of other paths.');for(const t of n.path)o.path.push(t)}return t(u(o))};function f(e,r){const o=u(n(r));if(!o.absolute)return t(o);const a=u(n(e));if(o.origin!==a.origin)return t(o);if(!a.absolute)return t(o);if(a.drive!==o.drive)return t(o);const l=Math.min(a.path.length,o.path.length);for(let t=0;t<l&&a.path[0]===o.path[0];t++)a.path.shift(),o.path.shift();return o.path.unshift(...a.path.fill("..")),t({origin:null,drive:null,absolute:!1,protocol:null,path:o.path})}function g(...e){if(0===e.length)return".";const r=u(n(e[e.length-1]));return r.absolute?t(r):h(...e)}const b="/",d=t=>{return null!==n(t).drive};function k(t){const[e,r,n,...o]=t.split("/"),u=o.length?`/${o.join("/")}`:void 0;let a,c;return u&&(c=i(u),a=l(u)),{shortcode:e,orgSlug:r,projectSlug:n,uri:u,file:a,ext:c}}function x({shortcode:t,orgSlug:e,projectSlug:r,uri:n=""}){return[t,e,r,n.replace(/^\//,"")].filter(Boolean).join("/")}export{l as basename,k as deserializeSrn,c as dirname,i as extname,t as format,s as isAbsolute,p as isURL,h as join,o as normalize,n as parse,f as relative,g as resolve,b as sep,x as serializeSrn,d as startsWithWindowsDrive,o as toFSPath}; | ||
function t(t){let e="";return t.absolute&&("file"===t.protocol?(t.drive&&(e+=t.drive),e+="/"):(e+=t.protocol+"://",t.origin&&(e+=t.origin+"/"))),""===(e+=t.path.join("/"))&&(e="."),e}function e(t,n,r,o){this.message=t,this.expected=n,this.found=r,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}!function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}(e,Error),e.buildMessage=function(t,e){var n={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var e,n="";for(e=0;e<t.parts.length;e++)n+=t.parts[e]instanceof Array?u(t.parts[e][0])+"-"+u(t.parts[e][1]):u(t.parts[e]);return"["+(t.inverted?"^":"")+n+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function r(t){return t.charCodeAt(0).toString(16).toUpperCase()}function o(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+r(t)})}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+r(t)})}return"Expected "+function(t){var e,r,o,u=new Array(t.length);for(e=0;e<t.length;e++)u[e]=(o=t[e],n[o.type](o));if(u.sort(),u.length>0){for(e=1,r=1;e<u.length;e++)u[e-1]!==u[e]&&(u[r]=u[e],r++);u.length=r}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."};var n=function(t,n){n=void 0!==n?n:{};var r,o,u,a,l={},c={Path:0},i=0,s=[function(t,e,n,r){return{protocol:t,origin:e,absolute:!0,...n,...r}},function(t,e,n){return{protocol:t,origin:e,absolute:!0,...n,path:[]}},"http://",k("http://",!0),function(t){return"http"},"https://",k("https://",!0),function(t){return"https"},"",function(){return null},function(t,e,n){return{protocol:t,origin:null,absolute:!0,...e,...n}},"file://",k("file://",!0),"file:",k("file:",!0),function(t){return"file"},function(t,e){return{protocol:"file",origin:null,absolute:!0,...t,...e}},function(){return{drive:null}},/^[A-Za-z]/,x([["A","Z"],["a","z"]],!1,!1),":",k(":",!1),function(t){return{drive:t.toLowerCase()+":"}},function(){return{drive:null}},function(t){return{protocol:null,origin:null,absolute:!1,drive:null,...t}},function(t){return{path:t}},function(t,e){return[t,...e]},function(t){return[t]},".",k(".",!1),"/",k("/",!1),"\\",k("\\",!1),/^[^\/\\]/,x(["/","\\"],!0,!1)],p=[w(";!./ &;&.) &;(.# &;-"),w("%;\"/F#;%/=$;*/4$;./+$8$: $$#\"! )($'#(#'#(\"'#&'#.F &%;\"/<#;%/3$;,/*$8#:!##\"! )(#'#(\"'#&'#"),w(";#.# &;$"),w('%3"""5\'7#/\' 8!:$!! )'),w("%3%\"\"5(7&/' 8!:'!! )"),w('%$;5/�#*;5&&&#/"!&,).. &% (/& 8!:)! )'),w("%;'/<#;)/3$;./*$8#:*##\"! )(#'#(\"'#&'#"),w('%3+""5\'7,.) &3-""5%7./\' 8!:/!! )'),w('%;)/2#;./)$8":0""! )("\'#&\'#'),w(";*.# &;+"),w("%;4/& 8!:1! )"),w('%42""5!73/@#24""6475/1$;4/($8#:6#!")(#\'#("\'#&\'#'),w("% (/& 8!:7! )"),w('%;0/1#;./($8":8"! )("\'#&\'#'),w("%;//' 8!:9!! )"),w("%;1/;#;4/2$;//)$8#::#\"\" )(#'#(\"'#&'#./ &%;1/' 8!:;!! )"),w(";2.# &;3"),w('%$;5/�#*;5&&&#/"!&,).# & ('),w('%2<""6<7=/,#;4/#$+")("\'#&\'#'),w(" ("),w('2>""6>7?.) &2@""6@7A'),w('4B""5!7C')],h=0,f=[{line:1,column:1}],g=0,b=[],d=0;if("startRule"in n){if(!(n.startRule in c))throw new Error("Can't start parsing from rule \""+n.startRule+'".');i=c[n.startRule]}function k(t,e){return{type:"literal",text:t,ignoreCase:e}}function x(t,e,n){return{type:"class",parts:t,inverted:e,ignoreCase:n}}function $(e){var n,r=f[e];if(r)return r;for(n=e-1;!f[n];)n--;for(r={line:(r=f[n]).line,column:r.column};n<e;)10===t.charCodeAt(n)?(r.line++,r.column=1):r.column++,n++;return f[e]=r,r}function v(t,e){var n=$(t),r=$(e);return{start:{offset:t,line:n.line,column:n.column},end:{offset:e,line:r.line,column:r.column}}}function m(t){h<g||(h>g&&(g=h,b=[]),b.push(t))}function w(t){var e,n=new Array(t.length);for(e=0;e<t.length;e++)n[e]=t.charCodeAt(e)-32;return n}if((r=function e(n){for(var r,o,u=p[n],a=0,c=[],i=u.length,f=[],g=[];;){for(;a<i;)switch(u[a]){case 0:g.push(s[u[a+1]]),a+=2;break;case 1:g.push(void 0),a++;break;case 2:g.push(null),a++;break;case 3:g.push(l),a++;break;case 4:g.push([]),a++;break;case 5:g.push(h),a++;break;case 6:g.pop(),a++;break;case 7:h=g.pop(),a++;break;case 8:g.length-=u[a+1],a+=2;break;case 9:g.splice(-2,1),a++;break;case 10:g[g.length-2].push(g.pop()),a++;break;case 11:g.push(g.splice(g.length-u[a+1],u[a+1])),a+=2;break;case 12:g.push(t.substring(g.pop(),h)),a++;break;case 13:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 14:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]===l?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 15:f.push(i),c.push(a+3+u[a+1]+u[a+2]),g[g.length-1]!==l?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 16:g[g.length-1]!==l?(f.push(i),c.push(a),i=a+2+u[a+1],a+=2):a+=2+u[a+1];break;case 17:f.push(i),c.push(a+3+u[a+1]+u[a+2]),t.length>h?(i=a+3+u[a+1],a+=3):(i=a+3+u[a+1]+u[a+2],a+=3+u[a+1]);break;case 18:f.push(i),c.push(a+4+u[a+2]+u[a+3]),t.substr(h,s[u[a+1]].length)===s[u[a+1]]?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 19:f.push(i),c.push(a+4+u[a+2]+u[a+3]),t.substr(h,s[u[a+1]].length).toLowerCase()===s[u[a+1]]?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 20:f.push(i),c.push(a+4+u[a+2]+u[a+3]),s[u[a+1]].test(t.charAt(h))?(i=a+4+u[a+2],a+=4):(i=a+4+u[a+2]+u[a+3],a+=4+u[a+2]);break;case 21:g.push(t.substr(h,u[a+1])),h+=u[a+1],a+=2;break;case 22:g.push(s[u[a+1]]),h+=s[u[a+1]].length,a+=2;break;case 23:g.push(l),0===d&&m(s[u[a+1]]),a+=2;break;case 24:g[g.length-1-u[a+1]],a+=2;break;case 25:a++;break;case 26:for(r=u.slice(a+4,a+4+u[a+3]),o=0;o<u[a+3];o++)r[o]=g[g.length-1-r[o]];g.splice(g.length-u[a+2],u[a+2],s[u[a+1]].apply(null,r)),a+=4+u[a+3];break;case 27:g.push(e(u[a+1])),a+=2;break;case 28:d++,a++;break;case 29:d--,a++;break;default:throw new Error("Invalid opcode: "+u[a]+".")}if(!(f.length>0))break;i=f.pop(),a=c.pop()}return g[0]}(i))!==l&&h===t.length)return r;throw r!==l&&h<t.length&&m({type:"end"}),o=b,u=g<t.length?t.charAt(g):null,a=g<t.length?v(g,g+1):v(g,g),new e(e.buildMessage(o,u),o,u,a)};function r(t){if("string"!=typeof t)throw new Error(`@stoplight/path: Cannot parse ${t} because it is not a string`);return n(t,{})}function o(e){return t(u(r(e)))}function u(t){let e=t.path;e=e.filter(t=>""!==t&&"."!==t);const n=[];for(const r of e)".."===r&&n.length&&".."!==n[n.length-1]?n.pop():".."===r&&t.absolute||n.push(r);return t.path=n,t}function a(t){let e=t.lastIndexOf(".");".."===t&&(e=-1),"."===t&&(e=-1);let n=t,r="";return e>0&&(n=t.slice(0,e),r=t.slice(e)),{name:n,ext:r}}const l=(t,e)=>{const n=u(r(t)).path.pop();if(!n)return"";const{name:o,ext:l}=a(n);return!0===e||e===l?o:`${o}${l}`},c=e=>{const n=u(r(e));return n.path.pop(),t(u(n))},i=t=>{const e=u(r(t)).path.pop();if(!e)return"";const{ext:n}=a(e);return n};function s(t){return r(t).absolute}function p(t){const e=r(t);return"http"===e.protocol||"https"===e.protocol}const h=(...e)=>{if(0===e.length)return".";const n=e.map(r),o=Object.assign({},n[0]);for(let t=1;t<n.length;t++){const r=n[t];if(r.absolute)throw new Error('Cannot join an absolute path "'+e[t]+'" in the middle of other paths.');for(const t of r.path)o.path.push(t)}return t(u(o))};function f(e,n){const o=u(r(n));if(!o.absolute)return t(o);const a=u(r(e));if(o.origin!==a.origin)return t(o);if(!a.absolute)return t(o);if(a.drive!==o.drive)return t(o);const l=Math.min(a.path.length,o.path.length);for(let t=0;t<l&&a.path[0]===o.path[0];t++)a.path.shift(),o.path.shift();return o.path.unshift(...a.path.fill("..")),t({origin:null,drive:null,absolute:!1,protocol:null,path:o.path})}function g(...e){if(0===e.length)return".";const n=u(r(e[e.length-1]));return n.absolute?t(n):h(...e)}const b="/",d=t=>{return null!==r(t).drive};function k(t){const[e,n,r,...o]=t.split("/"),u=o.length?`/${o.join("/")}`:void 0;let l,c;return u&&(l=o.find(t=>t.includes(".")))&&(c=a(l).ext),{shortcode:e,orgSlug:n,projectSlug:r,uri:u,file:l,ext:c}}function x({shortcode:t,orgSlug:e,projectSlug:n,uri:r=""}){return[t,e,n,r.replace(/^\//,"")].filter(Boolean).join("/")}export{l as basename,k as deserializeSrn,c as dirname,i as extname,t as format,s as isAbsolute,p as isURL,h as join,o as normalize,r as parse,f as relative,g as resolve,b as sep,x as serializeSrn,d as startsWithWindowsDrive,o as toFSPath}; |
{ | ||
"name": "@stoplight/path", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32985