Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stoplight/path

Package Overview
Dependencies
Maintainers
28
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/path - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

2

index.cjs.js

@@ -1,1 +0,1 @@

"use strict";function format(r){let t="";return r.absolute&&("file"===r.protocol?(r.drive&&(t+=r.drive),t+="/"):(t+=r.protocol+"://",r.origin&&(t+=r.origin+"/"))),""===(t+=r.path.join("/"))&&(t="."),t}function peg$subclass(r,t){function e(){this.constructor=r}e.prototype=t.prototype,r.prototype=new e}function peg$SyntaxError(r,t,e,n){this.message=r,this.expected=t,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(r,t){t=void 0!==t?t:{};var e,n,o,a,i={},u={Path:rr},s=rr,l=function(r,t,e,n){return{protocol:r,origin:t,absolute:!0,...e,...n}},c=function(r,t,e){return{protocol:r,origin:t,absolute:!0,...e,path:[]}},p="http://",f=N("http://",!0),h=function(r){return"http"},g="https://",d=N("https://",!0),m=function(r){return"https"},x="",v=function(){return null},b=function(r,t,e){return{protocol:r,origin:null,absolute:!0,...t,...e}},y="file://",S=N("file://",!0),z="file:",w=N("file:",!0),A=function(r){return"file"},C=function(r,t){return{protocol:"file",origin:null,absolute:!0,...r,...t}},E=function(){return{drive:null}},$=/^[A-Za-z]/,j=Q([["A","Z"],["a","z"]],!1,!1),P=":",R=N(":",!1),F=function(r){return{drive:r.toLowerCase()+":"}},L=function(){return{drive:null}},B=function(r){return{protocol:null,origin:null,absolute:!1,drive:null,...r}},W=function(r){return{path:r}},M=function(r,t){return[r,...t]},U=function(r){return[r]},_=".",D=N(".",!1),O="/",k=N("/",!1),T="\\",Z=N("\\",!1),I=/^[^\/\\]/,q=Q(["/","\\"],!0,!1),G=0,H=[{line:1,column:1}],J=0,K=[];if("startRule"in t){if(!(t.startRule in u))throw new Error("Can't start parsing from rule \""+t.startRule+'".');s=u[t.startRule]}function N(r,t){return{type:"literal",text:r,ignoreCase:t}}function Q(r,t,e){return{type:"class",parts:r,inverted:t,ignoreCase:e}}function V(t){var e,n=H[t];if(n)return n;for(e=t-1;!H[e];)e--;for(n={line:(n=H[e]).line,column:n.column};e<t;)10===r.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return H[t]=n,n}function X(r,t){var e=V(r),n=V(t);return{start:{offset:r,line:e.line,column:e.column},end:{offset:t,line:n.line,column:n.column}}}function Y(r){G<J||(G>J&&(J=G,K=[]),K.push(r))}function rr(){var t;return(t=function(){var r,t,e,n,o;r=G,(t=tr())!==i&&(e=er())!==i&&(n=or())!==i&&(o=ar())!==i?(t=l(t,e,n,o),r=t):(G=r,r=i);r===i&&(r=G,(t=tr())!==i&&(e=er())!==i&&(n=function(){var r;G,(r=x)!==i&&(r=L());return r}())!==i?(t=c(t,e,n),r=t):(G=r,r=i));return r}())===i&&(t=function(){var t,e,n,o;t=G,(e=function(){var t;return r.substr(G,7).toLowerCase()===y?(t=r.substr(G,7),G+=7):(t=i,Y(S)),t===i&&(r.substr(G,5).toLowerCase()===z?(t=r.substr(G,5),G+=5):(t=i,Y(w))),t!==i&&(t=A()),t}())!==i&&(n=nr())!==i&&(o=ar())!==i?(e=b(e,n,o),t=e):(G=t,t=i);return t}())===i&&(t=function(){var r,t,e;r=G,(t=nr())!==i&&(e=ar())!==i?(t=C(t,e),r=t):(G=r,r=i);return r}())===i&&(t=function(){var t,e,n;t=G,(e=function(){var t;return(t=function(){var t,e,n;return t=G,46===r.charCodeAt(G)?(e=_,G++):(e=i,Y(D)),e!==i&&(n=ur())!==i?t=e=[e,n]:(G=t,t=i),t}())===i&&(t=x),t}())!==i&&(n=ar())!==i?(e=B(n),t=e):(G=t,t=i);return t}()),t}function tr(){var t;return(t=function(){var t;G,r.substr(G,7).toLowerCase()===p?(t=r.substr(G,7),G+=7):(t=i,Y(f));t!==i&&(t=h());return t}())===i&&(t=function(){var t;G,r.substr(G,8).toLowerCase()===g?(t=r.substr(G,8),G+=8):(t=i,Y(d));t!==i&&(t=m());return t}()),t}function er(){var t,e,n;if(t=G,e=[],(n=sr())!==i)for(;n!==i;)e.push(n),n=sr();else e=i;return(t=e!==i?r.substring(t,G):e)===i&&(t=G,(e=x)!==i&&(e=v()),t=e),t}function nr(){var t;return(t=or())===i&&(t=function(){var t,e,n;t=G,$.test(r.charAt(G))?(e=r.charAt(G),G++):(e=i,Y(j));e!==i?(58===r.charCodeAt(G)?(n=P,G++):(n=i,Y(R)),n!==i&&ur()!==i?(e=F(e),t=e):(G=t,t=i)):(G=t,t=i);return t}()),t}function or(){var r;return G,(r=ur())!==i&&(r=E()),r}function ar(){var r;return G,(r=function r(){var t,e,n;t=G;e=ir();e!==i&&ur()!==i&&(n=r())!==i?(e=M(e,n),t=e):(G=t,t=i);t===i&&(t=G,(e=ir())!==i&&(e=U(e)),t=e);return t}())!==i&&(r=W(r)),r}function ir(){var t,e,n;if(t=G,e=[],(n=sr())!==i)for(;n!==i;)e.push(n),n=sr();else e=i;return(t=e!==i?r.substring(t,G):e)===i&&(t=x),t}function ur(){var t;return 47===r.charCodeAt(G)?(t=O,G++):(t=i,Y(k)),t===i&&(92===r.charCodeAt(G)?(t=T,G++):(t=i,Y(Z))),t}function sr(){var t;return I.test(r.charAt(G))?(t=r.charAt(G),G++):(t=i,Y(q)),t}if((e=s())!==i&&G===r.length)return e;throw e!==i&&G<r.length&&Y({type:"end"}),n=K,o=J<r.length?r.charAt(J):null,a=J<r.length?X(J,J+1):X(J,J),new peg$SyntaxError(peg$SyntaxError.buildMessage(n,o),n,o,a)}Object.defineProperty(exports,"__esModule",{value:!0}),peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(r,t){var e={literal:function(r){return'"'+o(r.text)+'"'},class:function(r){var t,e="";for(t=0;t<r.parts.length;t++)e+=r.parts[t]instanceof Array?a(r.parts[t][0])+"-"+a(r.parts[t][1]):a(r.parts[t]);return"["+(r.inverted?"^":"")+e+"]"},any:function(r){return"any character"},end:function(r){return"end of input"},other:function(r){return r.description}};function n(r){return r.charCodeAt(0).toString(16).toUpperCase()}function o(r){return r.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(r){return"\\x0"+n(r)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(r){return"\\x"+n(r)})}function a(r){return r.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(r){return"\\x0"+n(r)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(r){return"\\x"+n(r)})}return"Expected "+function(r){var t,n,o,a=new Array(r.length);for(t=0;t<r.length;t++)a[t]=(o=r[t],e[o.type](o));if(a.sort(),a.length>0){for(t=1,n=1;t<a.length;t++)a[t-1]!==a[t]&&(a[n]=a[t],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(r)+" but "+function(r){return r?'"'+o(r)+'"':"end of input"}(t)+" found."};var grammar={SyntaxError:peg$SyntaxError,parse:peg$parse},grammar_1=grammar.parse;function parse(r){if("string"!=typeof r)throw new Error(`@stoplight/path: Cannot parse ${r} because it is not a string`);return grammar_1(r,{})}function normalize(r){return format(normalizeParsed(parse(r)))}function normalizeParsed(r){let t=r.path;t=t.filter(r=>""!==r&&"."!==r);const e=[];for(const n of t)".."===n&&e.length&&".."!==e[e.length-1]?e.pop():".."===n&&r.absolute||e.push(n);return r.path=e,r}function parseBase(r){let t=r.lastIndexOf(".");".."===r&&(t=-1),"."===r&&(t=-1);let e=r,n="";return t>0&&(e=r.slice(0,t),n=r.slice(t)),{name:e,ext:n}}const basename=(r,t)=>{const e=normalizeParsed(parse(r)).path.pop();if(!e)return"";const{name:n,ext:o}=parseBase(e);return!0===t||t===o?n:`${n}${o}`},dirname=r=>{const t=normalizeParsed(parse(r));return t.path.pop(),format(normalizeParsed(t))},extname=r=>{const t=normalizeParsed(parse(r)).path.pop();if(!t)return"";const{ext:e}=parseBase(t);return e};function isAbsolute(r){return parse(r).absolute}function isURL(r){const t=parse(r);return"http"===t.protocol||"https"===t.protocol}const join=(...r)=>{if(0===r.length)return".";const t=r.map(parse),e=Object.assign({},t[0]);for(let n=1;n<t.length;n++){const o=t[n];if(o.absolute)throw new Error('Cannot join an absolute path "'+r[n]+'" in the middle of other paths.');for(const r of o.path)e.path.push(r)}return format(normalizeParsed(e))};function relative(r,t){const e=normalizeParsed(parse(t));if(!e.absolute)return format(e);const n=normalizeParsed(parse(r));if(e.origin!==n.origin)return format(e);if(!n.absolute)return format(e);if(n.drive!==e.drive)return format(e);const o=Math.min(n.path.length,e.path.length);for(let r=0;r<o&&n.path[0]===e.path[0];r++)n.path.shift(),e.path.shift();return e.path.unshift(...n.path.fill("..")),format({origin:null,drive:null,absolute:!1,protocol:null,path:e.path})}function resolve(...r){if(0===r.length)return".";const t=normalizeParsed(parse(r[r.length-1]));return t.absolute?format(t):join(...r)}const sep="/",startsWithWindowsDrive=r=>{return null!==parse(r).drive},stripRoot=r=>parse(r).path.filter(Boolean).join("/");function deserializeSrn(r){const[t,e,n,...o]=r.split("/"),a=o.length?`/${o.join("/")}`:void 0;let i,u;return a&&(i=o.find(r=>r.includes(".")))&&(u=parseBase(i).ext),{shortcode:t,orgSlug:e,projectSlug:n,uri:a,file:i,ext:u}}function serializeSrn({shortcode:r,orgSlug:t,projectSlug:e,uri:n=""}){return[r,t,e,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.stripRoot=stripRoot,exports.toFSPath=normalize;
"use strict";function format(r){let t="";return r.absolute&&("file"===r.protocol?(r.drive&&(t+=r.drive),t+="/"):(t+=r.protocol+"://",r.origin&&(t+=r.origin+"/"))),""===(t+=r.path.join("/"))&&(t="."),t}function peg$subclass(r,t){function e(){this.constructor=r}e.prototype=t.prototype,r.prototype=new e}function peg$SyntaxError(r,t,e,n){this.message=r,this.expected=t,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(r,t){t=void 0!==t?t:{};var e,n,o,a,i={},u={Path:rr},s=rr,l=function(r,t,e,n){return{protocol:r,origin:t,absolute:!0,...e,...n}},c=function(r,t,e){return{protocol:r,origin:t,absolute:!0,...e,path:[]}},p="http://",f=N("http://",!0),h=function(r){return"http"},g="https://",d=N("https://",!0),m=function(r){return"https"},x="",v=function(){return null},b=function(r,t,e){return{protocol:r,origin:null,absolute:!0,...t,...e}},y="file://",S=N("file://",!0),z="file:",w=N("file:",!0),A=function(r){return"file"},C=function(r,t){return{protocol:"file",origin:null,absolute:!0,...r,...t}},E=/^[A-Za-z]/,$=Q([["A","Z"],["a","z"]],!1,!1),j=":",P=N(":",!1),R=function(r){return{drive:r.toLowerCase()+":"}},F=function(){return{drive:null}},L=function(){return{drive:null}},B=function(r){return{protocol:null,origin:null,absolute:!1,drive:null,...r}},W=function(r){return{path:r}},M=function(r,t){return[r,...t]},U=function(r){return[r]},_=".",D=N(".",!1),O="/",k=N("/",!1),T="\\",Z=N("\\",!1),I=/^[^\/\\]/,q=Q(["/","\\"],!0,!1),G=0,H=[{line:1,column:1}],J=0,K=[];if("startRule"in t){if(!(t.startRule in u))throw new Error("Can't start parsing from rule \""+t.startRule+'".');s=u[t.startRule]}function N(r,t){return{type:"literal",text:r,ignoreCase:t}}function Q(r,t,e){return{type:"class",parts:r,inverted:t,ignoreCase:e}}function V(t){var e,n=H[t];if(n)return n;for(e=t-1;!H[e];)e--;for(n={line:(n=H[e]).line,column:n.column};e<t;)10===r.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return H[t]=n,n}function X(r,t){var e=V(r),n=V(t);return{start:{offset:r,line:e.line,column:e.column},end:{offset:t,line:n.line,column:n.column}}}function Y(r){G<J||(G>J&&(J=G,K=[]),K.push(r))}function rr(){var t;return(t=function(){var r,t,e,n,o;r=G,(t=tr())!==i&&(e=er())!==i&&(n=or())!==i&&(o=ar())!==i?(t=l(t,e,n,o),r=t):(G=r,r=i);r===i&&(r=G,(t=tr())!==i&&(e=er())!==i&&(n=function(){var r;G,(r=x)!==i&&(r=L());return r}())!==i?(t=c(t,e,n),r=t):(G=r,r=i));return r}())===i&&(t=function(){var t,e,n,o;t=G,(e=function(){var t;return r.substr(G,7).toLowerCase()===y?(t=r.substr(G,7),G+=7):(t=i,Y(S)),t===i&&(r.substr(G,5).toLowerCase()===z?(t=r.substr(G,5),G+=5):(t=i,Y(w))),t!==i&&(t=A()),t}())!==i&&(n=nr())!==i&&(o=ar())!==i?(e=b(e,n,o),t=e):(G=t,t=i);return t}())===i&&(t=function(){var r,t,e;r=G,(t=nr())!==i&&(e=ar())!==i?(t=C(t,e),r=t):(G=r,r=i);return r}())===i&&(t=function(){var t,e,n;t=G,(e=function(){var t;return(t=function(){var t,e,n;return t=G,46===r.charCodeAt(G)?(e=_,G++):(e=i,Y(D)),e!==i&&(n=ur())!==i?t=e=[e,n]:(G=t,t=i),t}())===i&&(t=x),t}())!==i&&(n=ar())!==i?(e=B(n),t=e):(G=t,t=i);return t}()),t}function tr(){var t;return(t=function(){var t;G,r.substr(G,7).toLowerCase()===p?(t=r.substr(G,7),G+=7):(t=i,Y(f));t!==i&&(t=h());return t}())===i&&(t=function(){var t;G,r.substr(G,8).toLowerCase()===g?(t=r.substr(G,8),G+=8):(t=i,Y(d));t!==i&&(t=m());return t}()),t}function er(){var t,e,n;if(t=G,e=[],(n=sr())!==i)for(;n!==i;)e.push(n),n=sr();else e=i;return(t=e!==i?r.substring(t,G):e)===i&&(t=G,(e=x)!==i&&(e=v()),t=e),t}function nr(){var t;return(t=function(){var t,e,n,o;t=G,(e=ur())===i&&(e=null);e!==i?(E.test(r.charAt(G))?(n=r.charAt(G),G++):(n=i,Y($)),n!==i?(58===r.charCodeAt(G)?(o=j,G++):(o=i,Y(P)),o!==i&&ur()!==i?(e=R(n),t=e):(G=t,t=i)):(G=t,t=i)):(G=t,t=i);return t}())===i&&(t=or()),t}function or(){var r;return G,(r=ur())!==i&&(r=F()),r}function ar(){var r;return G,(r=function r(){var t,e,n;t=G;e=ir();e!==i&&ur()!==i&&(n=r())!==i?(e=M(e,n),t=e):(G=t,t=i);t===i&&(t=G,(e=ir())!==i&&(e=U(e)),t=e);return t}())!==i&&(r=W(r)),r}function ir(){var t,e,n;if(t=G,e=[],(n=sr())!==i)for(;n!==i;)e.push(n),n=sr();else e=i;return(t=e!==i?r.substring(t,G):e)===i&&(t=x),t}function ur(){var t;return 47===r.charCodeAt(G)?(t=O,G++):(t=i,Y(k)),t===i&&(92===r.charCodeAt(G)?(t=T,G++):(t=i,Y(Z))),t}function sr(){var t;return I.test(r.charAt(G))?(t=r.charAt(G),G++):(t=i,Y(q)),t}if((e=s())!==i&&G===r.length)return e;throw e!==i&&G<r.length&&Y({type:"end"}),n=K,o=J<r.length?r.charAt(J):null,a=J<r.length?X(J,J+1):X(J,J),new peg$SyntaxError(peg$SyntaxError.buildMessage(n,o),n,o,a)}Object.defineProperty(exports,"__esModule",{value:!0}),peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(r,t){var e={literal:function(r){return'"'+o(r.text)+'"'},class:function(r){var t,e="";for(t=0;t<r.parts.length;t++)e+=r.parts[t]instanceof Array?a(r.parts[t][0])+"-"+a(r.parts[t][1]):a(r.parts[t]);return"["+(r.inverted?"^":"")+e+"]"},any:function(r){return"any character"},end:function(r){return"end of input"},other:function(r){return r.description}};function n(r){return r.charCodeAt(0).toString(16).toUpperCase()}function o(r){return r.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(r){return"\\x0"+n(r)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(r){return"\\x"+n(r)})}function a(r){return r.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(r){return"\\x0"+n(r)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(r){return"\\x"+n(r)})}return"Expected "+function(r){var t,n,o,a=new Array(r.length);for(t=0;t<r.length;t++)a[t]=(o=r[t],e[o.type](o));if(a.sort(),a.length>0){for(t=1,n=1;t<a.length;t++)a[t-1]!==a[t]&&(a[n]=a[t],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(r)+" but "+function(r){return r?'"'+o(r)+'"':"end of input"}(t)+" found."};var grammar={SyntaxError:peg$SyntaxError,parse:peg$parse},grammar_1=grammar.parse;function parse(r){if("string"!=typeof r)throw new Error(`@stoplight/path: Cannot parse ${r} because it is not a string`);return grammar_1(r,{})}function normalize(r){return format(normalizeParsed(parse(r)))}function normalizeParsed(r){let t=r.path;t=t.filter(r=>""!==r&&"."!==r);const e=[];for(const n of t)".."===n&&e.length&&".."!==e[e.length-1]?e.pop():".."===n&&r.absolute||e.push(n);return r.path=e,r}function parseBase(r){let t=r.lastIndexOf(".");".."===r&&(t=-1),"."===r&&(t=-1);let e=r,n="";return t>0&&(e=r.slice(0,t),n=r.slice(t)),{name:e,ext:n}}const basename=(r,t)=>{const e=normalizeParsed(parse(r)).path.pop();if(!e)return"";const{name:n,ext:o}=parseBase(e);return!0===t||t===o?n:`${n}${o}`},dirname=r=>{const t=normalizeParsed(parse(r));return t.path.pop(),format(normalizeParsed(t))},extname=r=>{const t=normalizeParsed(parse(r)).path.pop();if(!t)return"";const{ext:e}=parseBase(t);return e};function isAbsolute(r){return parse(r).absolute}function isURL(r){const t=parse(r);return"http"===t.protocol||"https"===t.protocol}const join=(...r)=>{if(0===r.length)return".";const t=r.map(parse),e=Object.assign({},t[0]);for(let n=1;n<t.length;n++){const o=t[n];if(o.absolute)throw new Error('Cannot join an absolute path "'+r[n]+'" in the middle of other paths.');for(const r of o.path)e.path.push(r)}return format(normalizeParsed(e))};function relative(r,t){const e=normalizeParsed(parse(t));if(!e.absolute)return format(e);const n=normalizeParsed(parse(r));if(e.origin!==n.origin)return format(e);if(!n.absolute)return format(e);if(n.drive!==e.drive)return format(e);const o=Math.min(n.path.length,e.path.length);for(let r=0;r<o&&n.path[0]===e.path[0];r++)n.path.shift(),e.path.shift();return e.path.unshift(...n.path.fill("..")),format({origin:null,drive:null,absolute:!1,protocol:null,path:e.path})}function resolve(...r){if(0===r.length)return".";const t=normalizeParsed(parse(r[r.length-1]));return t.absolute?format(t):join(...r)}const sep="/",startsWithWindowsDrive=r=>{return null!==parse(r).drive},stripRoot=r=>parse(r).path.filter(Boolean).join("/");function deserializeSrn(r){const[t,e,n,...o]=r.split("/"),a=o.length?`/${o.join("/")}`:void 0;let i,u;return a&&(i=o.find(r=>r.includes(".")))&&(u=parseBase(i).ext),{shortcode:t,orgSlug:e,projectSlug:n,uri:a,file:i,ext:u}}function serializeSrn({shortcode:r,orgSlug:t,projectSlug:e,uri:n=""}){return[r,t,e,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.stripRoot=stripRoot,exports.toFSPath=normalize;

@@ -1,1 +0,1 @@

function t(t){let n="";return t.absolute&&("file"===t.protocol?(t.drive&&(n+=t.drive),n+="/"):(n+=t.protocol+"://",t.origin&&(n+=t.origin+"/"))),""===(n+=t.path.join("/"))&&(n="."),n}function n(t,r,e,o){this.message=t,this.expected=r,this.found=e,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n)}!function(t,n){function r(){this.constructor=t}r.prototype=n.prototype,t.prototype=new r}(n,Error),n.buildMessage=function(t,n){var r={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var n,r="";for(n=0;n<t.parts.length;n++)r+=t.parts[n]instanceof Array?u(t.parts[n][0])+"-"+u(t.parts[n][1]):u(t.parts[n]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function e(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"+e(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+e(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"+e(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+e(t)})}return"Expected "+function(t){var n,e,o,u=new Array(t.length);for(n=0;n<t.length;n++)u[n]=(o=t[n],r[o.type](o));if(u.sort(),u.length>0){for(n=1,e=1;n<u.length;n++)u[n-1]!==u[n]&&(u[e]=u[n],e++);u.length=e}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"}(n)+" found."};var r=function(t,r){r=void 0!==r?r:{};var e,o,u,i,c={},a={Path:nt},l=nt,s=function(t,n,r,e){return{protocol:t,origin:n,absolute:!0,...r,...e}},f=function(t,n,r){return{protocol:t,origin:n,absolute:!0,...r,path:[]}},p="http://",h=W("http://",!0),g=function(t){return"http"},v="https://",d=W("https://",!0),b=function(t){return"https"},x="",m=function(){return null},C=function(t,n,r){return{protocol:t,origin:null,absolute:!0,...n,...r}},w="file://",A=W("file://",!0),y="file:",j=W("file:",!0),F=function(t){return"file"},S=function(t,n){return{protocol:"file",origin:null,absolute:!0,...t,...n}},E=function(){return{drive:null}},L=/^[A-Za-z]/,R=X([["A","Z"],["a","z"]],!1,!1),$=":",M=W(":",!1),k=function(t){return{drive:t.toLowerCase()+":"}},z=function(){return{drive:null}},B=function(t){return{protocol:null,origin:null,absolute:!1,drive:null,...t}},O=function(t){return{path:t}},P=function(t,n){return[t,...n]},T=function(t){return[t]},Z=".",I=W(".",!1),U="/",q=W("/",!1),D="\\",G=W("\\",!1),H=/^[^\/\\]/,J=X(["/","\\"],!0,!1),K=0,N=[{line:1,column:1}],Q=0,V=[];if("startRule"in r){if(!(r.startRule in a))throw new Error("Can't start parsing from rule \""+r.startRule+'".');l=a[r.startRule]}function W(t,n){return{type:"literal",text:t,ignoreCase:n}}function X(t,n,r){return{type:"class",parts:t,inverted:n,ignoreCase:r}}function Y(n){var r,e=N[n];if(e)return e;for(r=n-1;!N[r];)r--;for(e={line:(e=N[r]).line,column:e.column};r<n;)10===t.charCodeAt(r)?(e.line++,e.column=1):e.column++,r++;return N[n]=e,e}function _(t,n){var r=Y(t),e=Y(n);return{start:{offset:t,line:r.line,column:r.column},end:{offset:n,line:e.line,column:e.column}}}function tt(t){K<Q||(K>Q&&(Q=K,V=[]),V.push(t))}function nt(){var n;return(n=function(){var t,n,r,e,o;return t=K,(n=rt())!==c&&(r=et())!==c&&(e=ut())!==c&&(o=it())!==c?(n=s(n,r,e,o),t=n):(K=t,t=c),t===c&&(t=K,(n=rt())!==c&&(r=et())!==c&&(e=function(){var t;return(t=x)!==c&&(t=z()),t}())!==c?(n=f(n,r,e),t=n):(K=t,t=c)),t}())===c&&(n=function(){var n,r,e,o;return n=K,(r=function(){var n;return t.substr(K,7).toLowerCase()===w?(n=t.substr(K,7),K+=7):(n=c,tt(A)),n===c&&(t.substr(K,5).toLowerCase()===y?(n=t.substr(K,5),K+=5):(n=c,tt(j))),n!==c&&(n=F()),n}())!==c&&(e=ot())!==c&&(o=it())!==c?(r=C(r,e,o),n=r):(K=n,n=c),n}())===c&&(n=function(){var t,n,r;return t=K,(n=ot())!==c&&(r=it())!==c?(n=S(n,r),t=n):(K=t,t=c),t}())===c&&(n=function(){var n,r,e;return n=K,(r=function(){var n;return(n=function(){var n,r,e;return n=K,46===t.charCodeAt(K)?(r=Z,K++):(r=c,tt(I)),r!==c&&(e=at())!==c?n=r=[r,e]:(K=n,n=c),n}())===c&&(n=x),n}())!==c&&(e=it())!==c?(r=B(e),n=r):(K=n,n=c),n}()),n}function rt(){var n,r;return t.substr(K,7).toLowerCase()===p?(r=t.substr(K,7),K+=7):(r=c,tt(h)),r!==c&&(r=g()),(n=r)===c&&(n=function(){var n;return t.substr(K,8).toLowerCase()===v?(n=t.substr(K,8),K+=8):(n=c,tt(d)),n!==c&&(n=b()),n}()),n}function et(){var n,r,e;if(n=K,r=[],(e=lt())!==c)for(;e!==c;)r.push(e),e=lt();else r=c;return(n=r!==c?t.substring(n,K):r)===c&&(n=K,(r=x)!==c&&(r=m()),n=r),n}function ot(){var n;return(n=ut())===c&&(n=function(){var n,r,e;return n=K,L.test(t.charAt(K))?(r=t.charAt(K),K++):(r=c,tt(R)),r!==c?(58===t.charCodeAt(K)?(e=$,K++):(e=c,tt(M)),e!==c&&at()!==c?(r=k(r),n=r):(K=n,n=c)):(K=n,n=c),n}()),n}function ut(){var t;return(t=at())!==c&&(t=E()),t}function it(){var t;return(t=function t(){var n,r,e;return n=K,(r=ct())!==c&&at()!==c&&(e=t())!==c?(r=P(r,e),n=r):(K=n,n=c),n===c&&(n=K,(r=ct())!==c&&(r=T(r)),n=r),n}())!==c&&(t=O(t)),t}function ct(){var n,r,e;if(n=K,r=[],(e=lt())!==c)for(;e!==c;)r.push(e),e=lt();else r=c;return(n=r!==c?t.substring(n,K):r)===c&&(n=x),n}function at(){var n;return 47===t.charCodeAt(K)?(n=U,K++):(n=c,tt(q)),n===c&&(92===t.charCodeAt(K)?(n=D,K++):(n=c,tt(G))),n}function lt(){var n;return H.test(t.charAt(K))?(n=t.charAt(K),K++):(n=c,tt(J)),n}if((e=l())!==c&&K===t.length)return e;throw e!==c&&K<t.length&&tt({type:"end"}),o=V,u=Q<t.length?t.charAt(Q):null,i=Q<t.length?_(Q,Q+1):_(Q,Q),new n(n.buildMessage(o,u),o,u,i)};function e(t){if("string"!=typeof t)throw new Error(`@stoplight/path: Cannot parse ${t} because it is not a string`);return r(t,{})}function o(n){return t(u(e(n)))}function u(t){let n=t.path;n=n.filter(t=>""!==t&&"."!==t);const r=[];for(const e of n)".."===e&&r.length&&".."!==r[r.length-1]?r.pop():".."===e&&t.absolute||r.push(e);return t.path=r,t}function i(t){let n=t.lastIndexOf(".");".."===t&&(n=-1),"."===t&&(n=-1);let r=t,e="";return n>0&&(r=t.slice(0,n),e=t.slice(n)),{name:r,ext:e}}const c=(t,n)=>{const r=u(e(t)).path.pop();if(!r)return"";const{name:o,ext:c}=i(r);return!0===n||n===c?o:`${o}${c}`},a=n=>{const r=u(e(n));return r.path.pop(),t(u(r))},l=t=>{const n=u(e(t)).path.pop();if(!n)return"";const{ext:r}=i(n);return r};function s(t){return e(t).absolute}function f(t){const n=e(t);return"http"===n.protocol||"https"===n.protocol}const p=(...n)=>{if(0===n.length)return".";const r=n.map(e),o=Object.assign({},r[0]);for(let t=1;t<r.length;t++){const e=r[t];if(e.absolute)throw new Error('Cannot join an absolute path "'+n[t]+'" in the middle of other paths.');for(const t of e.path)o.path.push(t)}return t(u(o))};function h(n,r){const o=u(e(r));if(!o.absolute)return t(o);const i=u(e(n));if(o.origin!==i.origin)return t(o);if(!i.absolute)return t(o);if(i.drive!==o.drive)return t(o);const c=Math.min(i.path.length,o.path.length);for(let t=0;t<c&&i.path[0]===o.path[0];t++)i.path.shift(),o.path.shift();return o.path.unshift(...i.path.fill("..")),t({origin:null,drive:null,absolute:!1,protocol:null,path:o.path})}function g(...n){if(0===n.length)return".";const r=u(e(n[n.length-1]));return r.absolute?t(r):p(...n)}const v="/",d=t=>{return null!==e(t).drive},b=t=>e(t).path.filter(Boolean).join("/");function x(t){const[n,r,e,...o]=t.split("/"),u=o.length?`/${o.join("/")}`:void 0;let c,a;return u&&(c=o.find(t=>t.includes(".")))&&(a=i(c).ext),{shortcode:n,orgSlug:r,projectSlug:e,uri:u,file:c,ext:a}}function m({shortcode:t,orgSlug:n,projectSlug:r,uri:e=""}){return[t,n,r,e.replace(/^\//,"")].filter(Boolean).join("/")}export{c as basename,x as deserializeSrn,a as dirname,l as extname,t as format,s as isAbsolute,f as isURL,p as join,o as normalize,e as parse,h as relative,g as resolve,v as sep,m as serializeSrn,d as startsWithWindowsDrive,b as stripRoot,o as toFSPath};
function t(t){let n="";return t.absolute&&("file"===t.protocol?(t.drive&&(n+=t.drive),n+="/"):(n+=t.protocol+"://",t.origin&&(n+=t.origin+"/"))),""===(n+=t.path.join("/"))&&(n="."),n}function n(t,r,e,o){this.message=t,this.expected=r,this.found=e,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n)}!function(t,n){function r(){this.constructor=t}r.prototype=n.prototype,t.prototype=new r}(n,Error),n.buildMessage=function(t,n){var r={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var n,r="";for(n=0;n<t.parts.length;n++)r+=t.parts[n]instanceof Array?u(t.parts[n][0])+"-"+u(t.parts[n][1]):u(t.parts[n]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function e(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"+e(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+e(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"+e(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+e(t)})}return"Expected "+function(t){var n,e,o,u=new Array(t.length);for(n=0;n<t.length;n++)u[n]=(o=t[n],r[o.type](o));if(u.sort(),u.length>0){for(n=1,e=1;n<u.length;n++)u[n-1]!==u[n]&&(u[e]=u[n],e++);u.length=e}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"}(n)+" found."};var r=function(t,r){r=void 0!==r?r:{};var e,o,u,i,c={},a={Path:nt},l=nt,s=function(t,n,r,e){return{protocol:t,origin:n,absolute:!0,...r,...e}},f=function(t,n,r){return{protocol:t,origin:n,absolute:!0,...r,path:[]}},p="http://",h=W("http://",!0),g=function(t){return"http"},v="https://",d=W("https://",!0),b=function(t){return"https"},x="",m=function(){return null},C=function(t,n,r){return{protocol:t,origin:null,absolute:!0,...n,...r}},w="file://",A=W("file://",!0),y="file:",j=W("file:",!0),F=function(t){return"file"},S=function(t,n){return{protocol:"file",origin:null,absolute:!0,...t,...n}},E=/^[A-Za-z]/,L=X([["A","Z"],["a","z"]],!1,!1),R=":",$=W(":",!1),M=function(t){return{drive:t.toLowerCase()+":"}},k=function(){return{drive:null}},z=function(){return{drive:null}},B=function(t){return{protocol:null,origin:null,absolute:!1,drive:null,...t}},O=function(t){return{path:t}},P=function(t,n){return[t,...n]},T=function(t){return[t]},Z=".",I=W(".",!1),U="/",q=W("/",!1),D="\\",G=W("\\",!1),H=/^[^\/\\]/,J=X(["/","\\"],!0,!1),K=0,N=[{line:1,column:1}],Q=0,V=[];if("startRule"in r){if(!(r.startRule in a))throw new Error("Can't start parsing from rule \""+r.startRule+'".');l=a[r.startRule]}function W(t,n){return{type:"literal",text:t,ignoreCase:n}}function X(t,n,r){return{type:"class",parts:t,inverted:n,ignoreCase:r}}function Y(n){var r,e=N[n];if(e)return e;for(r=n-1;!N[r];)r--;for(e={line:(e=N[r]).line,column:e.column};r<n;)10===t.charCodeAt(r)?(e.line++,e.column=1):e.column++,r++;return N[n]=e,e}function _(t,n){var r=Y(t),e=Y(n);return{start:{offset:t,line:r.line,column:r.column},end:{offset:n,line:e.line,column:e.column}}}function tt(t){K<Q||(K>Q&&(Q=K,V=[]),V.push(t))}function nt(){var n;return(n=function(){var t,n,r,e,o;return t=K,(n=rt())!==c&&(r=et())!==c&&(e=ut())!==c&&(o=it())!==c?(n=s(n,r,e,o),t=n):(K=t,t=c),t===c&&(t=K,(n=rt())!==c&&(r=et())!==c&&(e=function(){var t;return(t=x)!==c&&(t=z()),t}())!==c?(n=f(n,r,e),t=n):(K=t,t=c)),t}())===c&&(n=function(){var n,r,e,o;return n=K,(r=function(){var n;return t.substr(K,7).toLowerCase()===w?(n=t.substr(K,7),K+=7):(n=c,tt(A)),n===c&&(t.substr(K,5).toLowerCase()===y?(n=t.substr(K,5),K+=5):(n=c,tt(j))),n!==c&&(n=F()),n}())!==c&&(e=ot())!==c&&(o=it())!==c?(r=C(r,e,o),n=r):(K=n,n=c),n}())===c&&(n=function(){var t,n,r;return t=K,(n=ot())!==c&&(r=it())!==c?(n=S(n,r),t=n):(K=t,t=c),t}())===c&&(n=function(){var n,r,e;return n=K,(r=function(){var n;return(n=function(){var n,r,e;return n=K,46===t.charCodeAt(K)?(r=Z,K++):(r=c,tt(I)),r!==c&&(e=at())!==c?n=r=[r,e]:(K=n,n=c),n}())===c&&(n=x),n}())!==c&&(e=it())!==c?(r=B(e),n=r):(K=n,n=c),n}()),n}function rt(){var n,r;return t.substr(K,7).toLowerCase()===p?(r=t.substr(K,7),K+=7):(r=c,tt(h)),r!==c&&(r=g()),(n=r)===c&&(n=function(){var n;return t.substr(K,8).toLowerCase()===v?(n=t.substr(K,8),K+=8):(n=c,tt(d)),n!==c&&(n=b()),n}()),n}function et(){var n,r,e;if(n=K,r=[],(e=lt())!==c)for(;e!==c;)r.push(e),e=lt();else r=c;return(n=r!==c?t.substring(n,K):r)===c&&(n=K,(r=x)!==c&&(r=m()),n=r),n}function ot(){var n;return(n=function(){var n,r,e,o;return n=K,(r=at())===c&&(r=null),r!==c?(E.test(t.charAt(K))?(e=t.charAt(K),K++):(e=c,tt(L)),e!==c?(58===t.charCodeAt(K)?(o=R,K++):(o=c,tt($)),o!==c&&at()!==c?(r=M(e),n=r):(K=n,n=c)):(K=n,n=c)):(K=n,n=c),n}())===c&&(n=ut()),n}function ut(){var t;return(t=at())!==c&&(t=k()),t}function it(){var t;return(t=function t(){var n,r,e;return n=K,(r=ct())!==c&&at()!==c&&(e=t())!==c?(r=P(r,e),n=r):(K=n,n=c),n===c&&(n=K,(r=ct())!==c&&(r=T(r)),n=r),n}())!==c&&(t=O(t)),t}function ct(){var n,r,e;if(n=K,r=[],(e=lt())!==c)for(;e!==c;)r.push(e),e=lt();else r=c;return(n=r!==c?t.substring(n,K):r)===c&&(n=x),n}function at(){var n;return 47===t.charCodeAt(K)?(n=U,K++):(n=c,tt(q)),n===c&&(92===t.charCodeAt(K)?(n=D,K++):(n=c,tt(G))),n}function lt(){var n;return H.test(t.charAt(K))?(n=t.charAt(K),K++):(n=c,tt(J)),n}if((e=l())!==c&&K===t.length)return e;throw e!==c&&K<t.length&&tt({type:"end"}),o=V,u=Q<t.length?t.charAt(Q):null,i=Q<t.length?_(Q,Q+1):_(Q,Q),new n(n.buildMessage(o,u),o,u,i)};function e(t){if("string"!=typeof t)throw new Error(`@stoplight/path: Cannot parse ${t} because it is not a string`);return r(t,{})}function o(n){return t(u(e(n)))}function u(t){let n=t.path;n=n.filter(t=>""!==t&&"."!==t);const r=[];for(const e of n)".."===e&&r.length&&".."!==r[r.length-1]?r.pop():".."===e&&t.absolute||r.push(e);return t.path=r,t}function i(t){let n=t.lastIndexOf(".");".."===t&&(n=-1),"."===t&&(n=-1);let r=t,e="";return n>0&&(r=t.slice(0,n),e=t.slice(n)),{name:r,ext:e}}const c=(t,n)=>{const r=u(e(t)).path.pop();if(!r)return"";const{name:o,ext:c}=i(r);return!0===n||n===c?o:`${o}${c}`},a=n=>{const r=u(e(n));return r.path.pop(),t(u(r))},l=t=>{const n=u(e(t)).path.pop();if(!n)return"";const{ext:r}=i(n);return r};function s(t){return e(t).absolute}function f(t){const n=e(t);return"http"===n.protocol||"https"===n.protocol}const p=(...n)=>{if(0===n.length)return".";const r=n.map(e),o=Object.assign({},r[0]);for(let t=1;t<r.length;t++){const e=r[t];if(e.absolute)throw new Error('Cannot join an absolute path "'+n[t]+'" in the middle of other paths.');for(const t of e.path)o.path.push(t)}return t(u(o))};function h(n,r){const o=u(e(r));if(!o.absolute)return t(o);const i=u(e(n));if(o.origin!==i.origin)return t(o);if(!i.absolute)return t(o);if(i.drive!==o.drive)return t(o);const c=Math.min(i.path.length,o.path.length);for(let t=0;t<c&&i.path[0]===o.path[0];t++)i.path.shift(),o.path.shift();return o.path.unshift(...i.path.fill("..")),t({origin:null,drive:null,absolute:!1,protocol:null,path:o.path})}function g(...n){if(0===n.length)return".";const r=u(e(n[n.length-1]));return r.absolute?t(r):p(...n)}const v="/",d=t=>{return null!==e(t).drive},b=t=>e(t).path.filter(Boolean).join("/");function x(t){const[n,r,e,...o]=t.split("/"),u=o.length?`/${o.join("/")}`:void 0;let c,a;return u&&(c=o.find(t=>t.includes(".")))&&(a=i(c).ext),{shortcode:n,orgSlug:r,projectSlug:e,uri:u,file:c,ext:a}}function m({shortcode:t,orgSlug:n,projectSlug:r,uri:e=""}){return[t,n,r,e.replace(/^\//,"")].filter(Boolean).join("/")}export{c as basename,x as deserializeSrn,a as dirname,l as extname,t as format,s as isAbsolute,f as isURL,p as join,o as normalize,e as parse,h as relative,g as resolve,v as sep,m as serializeSrn,d as startsWithWindowsDrive,b as stripRoot,o as toFSPath};
{
"name": "@stoplight/path",
"version": "1.3.1",
"version": "1.3.2",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc