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

@howiefh/ant-path-matcher

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@howiefh/ant-path-matcher - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

0

babel.config.js
module.exports = {
presets: ['@babel/preset-env']
}

2

dist/ant-path-matcher.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AntPathMatcher=e():t.AntPathMatcher=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>n});var r=function(){function t(e){this.caseSensitive=!0,this.trimTokens=!1,this.cachePatterns=null,this.tokenizedPatternCache={},this.stringMatcherCache={},this.pathSeparator=e||t.DEFAULT_PATH_SEPARATOR,this.pathSeparatorPatternCache=new t.PathSeparatorPatternCache(this.pathSeparator)}return t.EMPTY_STRING_ARRAY_$LI$=function(){return null==t.EMPTY_STRING_ARRAY&&(t.EMPTY_STRING_ARRAY=[]),t.EMPTY_STRING_ARRAY},t.VARIABLE_PATTERN_$LI$=function(){return null==t.VARIABLE_PATTERN&&(t.VARIABLE_PATTERN=new RegExp("\\{[^/]+?}","g")),t.VARIABLE_PATTERN},t.WHITESPACE_$LI$=function(){return null==t.WHITESPACE&&(t.WHITESPACE=new RegExp("[\\t-\\r \\u1680\\u180E\\u2000-\\u2006\\u2008-\\u200A\\u2028\\u2029\\u205F\\u3000\\uFEFF]|[\\x1C-\\x1F]","g")),t.WHITESPACE},t.WILDCARD_CHARS_$LI$=function(){return null==t.WILDCARD_CHARS&&(t.WILDCARD_CHARS=["*","?","{"]),t.WILDCARD_CHARS},t.prototype.setPathSeparator=function(e){this.pathSeparator=e||t.DEFAULT_PATH_SEPARATOR,this.pathSeparatorPatternCache=new t.PathSeparatorPatternCache(this.pathSeparator)},t.prototype.setCaseSensitive=function(t){this.caseSensitive=t},t.prototype.setTrimTokens=function(t){this.trimTokens=t},t.prototype.setCachePatterns=function(t){this.cachePatterns=t},t.prototype.deactivatePatternCache=function(){this.cachePatterns=!1,this.tokenizedPatternCache={},this.stringMatcherCache={}},t.prototype.isPattern=function(t){if(!t)return!1;for(var e=!1,r=0;r<t.length;r++){var n=t.charAt(r);if("*"===n||"?"===n)return!0;if("{"!==n){if("}"===n&&e)return!0}else e=!0}return!1},t.prototype.match=function(t,e){return this.doMatch(t,e,!0,null)},t.prototype.matchStart=function(t,e){return this.doMatch(t,e,!1,null)},t.prototype.doMatch=function(t,e,r,n){if(null==e||e.startsWith(this.pathSeparator)!==t.startsWith(this.pathSeparator))return!1;var i=this.tokenizePattern(t);if(r&&this.caseSensitive&&!this.isPotentialMatch(e,i))return!1;for(var a=this.tokenizePath(e),s=0,h=i.length-1,o=0,u=a.length-1;s<=h&&o<=u&&"**"!==(p=i[s]);){if(!this.matchStrings(p,a[o],n))return!1;s++,o++}if(o>u){if(s>h)return t.endsWith(this.pathSeparator)===e.endsWith(this.pathSeparator);if(!r)return!0;if(s===h&&"*"===i[s]&&e.endsWith(this.pathSeparator))return!0;for(var c=s;c<=h;c++)if("**"!==i[c])return!1;return!0}if(s>h)return!1;if(!r&&"**"===i[s])return!0;for(;s<=h&&o<=u;){var p;if("**"===(p=i[h]))break;if(!this.matchStrings(p,a[u],n))return!1;h--,u--}if(o>u){for(c=s;c<=h;c++)if("**"!==i[c])return!1;return!0}for(;s!==h&&o<=u;){var l=-1;for(c=s+1;c<=h;c++)if("**"===i[c]){l=c;break}if(l!==s+1){var f=l-s-1,g=u-o+1,d=-1;t:for(c=0;c<=g-f;c++){for(var P=0;P<f;P++){var A=i[s+P+1],S=a[o+c+P];if(!this.matchStrings(A,S,n))continue t}d=o+c;break}if(-1===d)return!1;s=l,o=d+f}else s++}for(c=s;c<=h;c++)if("**"!==i[c])return!1;return!0},t.prototype.isPotentialMatch=function(t,e){if(!this.trimTokens)for(var r=0,n=0;n<e.length;n++){var i=e[n],a=this.skipSeparator(t,r,this.pathSeparator);if(r+=a,(a=this.skipSegment(t,r,i))<i.length)return a>0||i.length>0&&this.isWildcardChar(i.charAt(0));r+=a}return!0},t.prototype.skipSegment=function(t,e,r){for(var n=0,i=0;i<r.length;i++){var a=r.charAt(i);if(this.isWildcardChar(a))return n;var s=e+n;if(s>=t.length)return 0;a===t.charAt(s)&&n++}return n},t.prototype.skipSeparator=function(t,e,r){for(var n=0;t.startsWith(r,e+n);)n+=r.length;return n},t.prototype.isWildcardChar=function(e){for(var r=0;r<t.WILDCARD_CHARS_$LI$().length;r++)if(e===t.WILDCARD_CHARS_$LI$()[r])return!0;return!1},t.prototype.tokenizePattern=function(e){var r=null,n=this.cachePatterns;if((null==n||n)&&(r=void 0===(r=this.tokenizedPatternCache[e])?null:r),null==r){if(r=this.tokenizePath(e),null==n&&Object.keys(this.tokenizedPatternCache).length>=t.CACHE_TURNOFF_THRESHOLD)return this.deactivatePatternCache(),r;(null==n||n)&&(this.tokenizedPatternCache[e]=r)}return r},t.prototype.tokenizePath=function(e){return t.tokenizeToStringArray(e,this.pathSeparator,this.trimTokens,!0)},t.prototype.matchStrings=function(t,e,r){return this.getStringMatcher(t).matchStrings(e,r)},t.prototype.getStringMatcher=function(e){var r=null,n=this.cachePatterns;if((null==n||n)&&(r=void 0===(r=this.stringMatcherCache[e])?null:r),null==r){if(r=new t.AntPathStringMatcher(e,this.caseSensitive),null==n&&Object.keys(this.stringMatcherCache).length>=t.CACHE_TURNOFF_THRESHOLD)return this.deactivatePatternCache(),r;(null==n||n)&&(this.stringMatcherCache[e]=r)}return r},t.prototype.extractPathWithinPattern=function(e,r){for(var n=t.tokenizeToStringArray(e,this.pathSeparator,this.trimTokens,!0),i=t.tokenizeToStringArray(r,this.pathSeparator,this.trimTokens,!0),a="",s=!1,h=0;h<n.length;h++){var o=n[h];if(o.indexOf("*")>-1||o.indexOf("?")>-1)for(;h<i.length;h++)(s||0==h&&!e.startsWith(this.pathSeparator))&&(a+=this.pathSeparator),a+=i[h],s=!0}return a},t.prototype.extractUriTemplateVariables=function(t,e){var r={};if(!this.doMatch(t,e,!0,r))throw new Error('Pattern "'+t+'" is not a match for "'+e+'"');return r},t.prototype.combine=function(e,r){if(!t.hasText(e)&&!t.hasText(r))return"";if(!t.hasText(e))return r;if(!t.hasText(r))return e;var n=-1!==e.indexOf("{");if(e!==r&&!n&&this.match(e,r))return r;if(e.endsWith(this.pathSeparatorPatternCache.getEndsOnWildCard()))return this.concat(e.substring(0,e.length-2),r);if(e.endsWith(this.pathSeparatorPatternCache.getEndsOnDoubleWildCard()))return this.concat(e,r);var i=e.indexOf("*.");if(n||-1===i||"."===this.pathSeparator)return this.concat(e,r);var a=e.substring(i+1),s=r.indexOf("."),h=-1===s?r:r.substring(0,s),o=-1===s?"":r.substring(s),u=".*"===a||0===a.length,c=".*"===o||0===o.length;if(!u&&!c)throw new Error("Cannot combine patterns: "+e+" vs "+r);return h+(u?o:a)},t.prototype.concat=function(t,e){var r=t.endsWith(this.pathSeparator),n=e.startsWith(this.pathSeparator);return r&&n?t+e.substring(1):r||n?t+e:t+this.pathSeparator+e},t.prototype.getPatternComparator=function(e){return new t.AntPatternComparator(e)},t.hasText=function(e){return null!=e&&!(0===e.length)&&t.containsText(e)},t.containsText=function(e){for(var r=e.length,n=0;n<r;n++)if(!t.isWhitespace(e.charAt(n)))return!0;return!1},t.tokenizeToStringArray=function(e,r,n,i){if(null==e)return t.EMPTY_STRING_ARRAY_$LI$();for(var a=e.split(r),s=[],h=0;h<a.length;h++){var o=a[h];n&&(o=o.trim()),(!i||o.length>0)&&s.push(o)}return s},t.isWhitespace=function(e){return t.WHITESPACE_$LI$().test(e)},t.DEFAULT_PATH_SEPARATOR="/",t.CACHE_TURNOFF_THRESHOLD=65536,t}();!function(t){var e=function(){function t(e,r){this.exactMatch=!1,this.pattern=null,this.variableNames=[],this.rawPattern=e,this.caseSensitive=r;for(var n,i="",a=0;null!=(n=t.GLOB_PATTERN_$LI$().exec(e));){i+=this.quote(e,a,n.index);var s=n[0];if("?"===s)i+=".";else if("*"===s)i+=".*";else if(s.startsWith("{")&&s.endsWith("}")){var h=s.indexOf(":");if(-1===h)i+=t.DEFAULT_VARIABLE_PATTERN,this.variableNames.push(n[1]);else{i=i+"("+s.substring(h+1,s.length-1)+")";var o=s.substring(1,h);this.variableNames.push(o)}}a=t.GLOB_PATTERN_$LI$().lastIndex}0===a?(this.exactMatch=!0,this.pattern=null):(this.exactMatch=!1,i+=this.quote(e,a,e.length),this.pattern=this.caseSensitive?new RegExp(i,"usg"):new RegExp(i,"iusg"))}return t.GLOB_PATTERN_$LI$=function(){return null==t.GLOB_PATTERN&&(t.GLOB_PATTERN=new RegExp("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}","g")),t.GLOB_PATTERN},t.prototype.quote=function(t,e,r){return e===r?"":t=(t=t.substring(e,r)).replace(/[[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},t.prototype.matchStrings=function(t,e){if(this.exactMatch)return this.caseSensitive?this.rawPattern===t:this.rawPattern.toUpperCase()===(null===t?t:t.toUpperCase());var r,n;if(null!=this.pattern&&(r=this.pattern,n=t,new RegExp("^"+r.source+"$",r.flags).test(n))){if(null!=e){var i=function(t){return new RegExp(t.source+"|").exec("").length-1}(this.pattern);if(this.variableNames.length!==i)throw new Error("The number of capturing groups in the pattern segment "+this.pattern+" does not match the number of URI template variables it defines, which can occur if capturing groups are used in a URI template regex. Use non-capturing groups instead.");for(var a=function(t,e){return new RegExp(t.source,t.flags).exec(e)}(this.pattern,t),s=1;s<=i;s++){var h=this.variableNames[s-1],o=a[s];e[h]=o}}return!0}return!1},t.DEFAULT_VARIABLE_PATTERN="(.*)",t}();t.AntPathStringMatcher=e;var r=function(){function t(t){this.path=t}return t.prototype.compare=function(e,r){var n=new t.PatternInfo(e),i=new t.PatternInfo(r);if(n.isLeastSpecific()&&i.isLeastSpecific())return 0;if(n.isLeastSpecific())return 1;if(i.isLeastSpecific())return-1;var a=e===this.path,s=r===this.path;return a&&s?0:a?-1:s?1:n.isPrefixPattern()&&i.isPrefixPattern()?i.getLength()-n.getLength():n.isPrefixPattern()&&0===i.getDoubleWildcards()?1:i.isPrefixPattern()&&0===n.getDoubleWildcards()?-1:n.getTotalCount()!==i.getTotalCount()?n.getTotalCount()-i.getTotalCount():n.getLength()!==i.getLength()?i.getLength()-n.getLength():n.getSingleWildcards()<i.getSingleWildcards()?-1:i.getSingleWildcards()<n.getSingleWildcards()?1:n.getUriVars()<i.getUriVars()?-1:i.getUriVars()<n.getUriVars()?1:0},t}();t.AntPatternComparator=r,function(e){var r=function(){function e(t){this.uriVars=0,this.singleWildcards=0,this.doubleWildcards=0,this.catchAllPattern=!1,this.prefixPattern=!1,this.length=null,this.pattern=t,null!=this.pattern&&(this.initCounters(),this.catchAllPattern="/**"===this.pattern,this.prefixPattern=!this.catchAllPattern&&this.pattern.endsWith("/**")),0===this.uriVars&&(this.length=null!=this.pattern?this.pattern.length:0)}return e.prototype.initCounters=function(){var t=0;if(null!=this.pattern)for(;t<this.pattern.length;)"{"===this.pattern.charAt(t)?(this.uriVars++,t++):"*"===this.pattern.charAt(t)?t+1<this.pattern.length&&"*"===this.pattern.charAt(t+1)?(this.doubleWildcards++,t+=2):t>0&&".*"!==this.pattern.substring(t-1)?(this.singleWildcards++,t++):t++:t++},e.prototype.getUriVars=function(){return this.uriVars},e.prototype.getSingleWildcards=function(){return this.singleWildcards},e.prototype.getDoubleWildcards=function(){return this.doubleWildcards},e.prototype.isLeastSpecific=function(){return null==this.pattern||this.catchAllPattern},e.prototype.isPrefixPattern=function(){return this.prefixPattern},e.prototype.getTotalCount=function(){return this.uriVars+this.singleWildcards+2*this.doubleWildcards},e.prototype.getLength=function(){return null==this.length&&(this.length=null!=this.pattern?this.pattern.replace(t.VARIABLE_PATTERN_$LI$(),"#").length:0),this.length},e}();e.PatternInfo=r}(r=t.AntPatternComparator);var n=function(){function t(t){this.endsOnWildCard=t+"*",this.endsOnDoubleWildCard=t+"**"}return t.prototype.getEndsOnWildCard=function(){return this.endsOnWildCard},t.prototype.getEndsOnDoubleWildCard=function(){return this.endsOnDoubleWildCard},t}();t.PathSeparatorPatternCache=n}(r);const n=r;return e.default})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AntPathMatcher=e():t.AntPathMatcher=e()}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>n});var r=function(){function t(e){this.caseSensitive=!0,this.trimTokens=!1,this.cachePatterns=null,this.tokenizedPatternCache={},this.stringMatcherCache={},this.pathSeparator=e||t.DEFAULT_PATH_SEPARATOR,this.pathSeparatorPatternCache=new t.PathSeparatorPatternCache(this.pathSeparator)}return t.EMPTY_STRING_ARRAY_$LI$=function(){return null==t.EMPTY_STRING_ARRAY&&(t.EMPTY_STRING_ARRAY=[]),t.EMPTY_STRING_ARRAY},t.VARIABLE_PATTERN_$LI$=function(){return null==t.VARIABLE_PATTERN&&(t.VARIABLE_PATTERN=new RegExp("\\{[^/]+?}","g")),t.VARIABLE_PATTERN},t.WHITESPACE_$LI$=function(){return null==t.WHITESPACE&&(t.WHITESPACE=new RegExp("[\\t-\\r \\u1680\\u180E\\u2000-\\u2006\\u2008-\\u200A\\u2028\\u2029\\u205F\\u3000\\uFEFF]|[\\x1C-\\x1F]","g")),t.WHITESPACE},t.WILDCARD_CHARS_$LI$=function(){return null==t.WILDCARD_CHARS&&(t.WILDCARD_CHARS=["*","?","{"]),t.WILDCARD_CHARS},t.prototype.setPathSeparator=function(e){this.pathSeparator=e||t.DEFAULT_PATH_SEPARATOR,this.pathSeparatorPatternCache=new t.PathSeparatorPatternCache(this.pathSeparator)},t.prototype.setCaseSensitive=function(t){this.caseSensitive=t},t.prototype.setTrimTokens=function(t){this.trimTokens=t},t.prototype.setCachePatterns=function(t){this.cachePatterns=t},t.prototype.deactivatePatternCache=function(){this.cachePatterns=!1,this.tokenizedPatternCache={},this.stringMatcherCache={}},t.prototype.isPattern=function(t){if(!t)return!1;for(var e=!1,r=0;r<t.length;r++){var n=t.charAt(r);if("*"===n||"?"===n)return!0;if("{"!==n){if("}"===n&&e)return!0}else e=!0}return!1},t.prototype.match=function(t,e){return this.doMatch(t,e,!0,null)},t.prototype.matchStart=function(t,e){return this.doMatch(t,e,!1,null)},t.prototype.doMatch=function(t,e,r,n){if(null==e||e.startsWith(this.pathSeparator)!==t.startsWith(this.pathSeparator))return!1;var i=this.tokenizePattern(t);if(r&&this.caseSensitive&&!this.isPotentialMatch(e,i))return!1;for(var a=this.tokenizePath(e),s=0,h=i.length-1,o=0,u=a.length-1;s<=h&&o<=u&&"**"!==(p=i[s]);){if(!this.matchStrings(p,a[o],n))return!1;s++,o++}if(o>u){if(s>h)return t.endsWith(this.pathSeparator)===e.endsWith(this.pathSeparator);if(!r)return!0;if(s===h&&"*"===i[s]&&e.endsWith(this.pathSeparator))return!0;for(var c=s;c<=h;c++)if("**"!==i[c])return!1;return!0}if(s>h)return!1;if(!r&&"**"===i[s])return!0;for(;s<=h&&o<=u;){var p;if("**"===(p=i[h]))break;if(!this.matchStrings(p,a[u],n))return!1;h--,u--}if(o>u){for(c=s;c<=h;c++)if("**"!==i[c])return!1;return!0}for(;s!==h&&o<=u;){var l=-1;for(c=s+1;c<=h;c++)if("**"===i[c]){l=c;break}if(l!==s+1){var f=l-s-1,g=u-o+1,d=-1;t:for(c=0;c<=g-f;c++){for(var P=0;P<f;P++){var A=i[s+P+1],S=a[o+c+P];if(!this.matchStrings(A,S,n))continue t}d=o+c;break}if(-1===d)return!1;s=l,o=d+f}else s++}for(c=s;c<=h;c++)if("**"!==i[c])return!1;return!0},t.prototype.isPotentialMatch=function(t,e){if(!this.trimTokens)for(var r=0,n=0;n<e.length;n++){var i=e[n],a=this.skipSeparator(t,r,this.pathSeparator);if(r+=a,(a=this.skipSegment(t,r,i))<i.length)return a>0||i.length>0&&this.isWildcardChar(i.charAt(0));r+=a}return!0},t.prototype.skipSegment=function(t,e,r){for(var n=0,i=0;i<r.length;i++){var a=r.charAt(i);if(this.isWildcardChar(a))return n;var s=e+n;if(s>=t.length)return 0;a===t.charAt(s)&&n++}return n},t.prototype.skipSeparator=function(t,e,r){for(var n=0;t.startsWith(r,e+n);)n+=r.length;return n},t.prototype.isWildcardChar=function(e){for(var r=0;r<t.WILDCARD_CHARS_$LI$().length;r++)if(e===t.WILDCARD_CHARS_$LI$()[r])return!0;return!1},t.prototype.tokenizePattern=function(e){var r=null,n=this.cachePatterns;if((null==n||n)&&(r=void 0===(r=this.tokenizedPatternCache[e])?null:r),null==r){if(r=this.tokenizePath(e),null==n&&Object.keys(this.tokenizedPatternCache).length>=t.CACHE_TURNOFF_THRESHOLD)return this.deactivatePatternCache(),r;(null==n||n)&&(this.tokenizedPatternCache[e]=r)}return r},t.prototype.tokenizePath=function(e){return t.tokenizeToStringArray(e,this.pathSeparator,this.trimTokens,!0)},t.prototype.matchStrings=function(t,e,r){return this.getStringMatcher(t).matchStrings(e,r)},t.prototype.getStringMatcher=function(e){var r=null,n=this.cachePatterns;if((null==n||n)&&(r=void 0===(r=this.stringMatcherCache[e])?null:r),null==r){if(r=new t.AntPathStringMatcher(e,this.caseSensitive),null==n&&Object.keys(this.stringMatcherCache).length>=t.CACHE_TURNOFF_THRESHOLD)return this.deactivatePatternCache(),r;(null==n||n)&&(this.stringMatcherCache[e]=r)}return r},t.prototype.extractPathWithinPattern=function(e,r){for(var n=t.tokenizeToStringArray(e,this.pathSeparator,this.trimTokens,!0),i=t.tokenizeToStringArray(r,this.pathSeparator,this.trimTokens,!0),a="",s=!1,h=0;h<n.length;h++){var o=n[h];if(o.indexOf("*")>-1||o.indexOf("?")>-1)for(;h<i.length;h++)(s||0==h&&!e.startsWith(this.pathSeparator))&&(a+=this.pathSeparator),a+=i[h],s=!0}return a},t.prototype.extractUriTemplateVariables=function(t,e){var r={};if(!this.doMatch(t,e,!0,r))throw new Error('Pattern "'+t+'" is not a match for "'+e+'"');return r},t.prototype.combine=function(e,r){if(!t.hasText(e)&&!t.hasText(r))return"";if(!t.hasText(e))return r;if(!t.hasText(r))return e;var n=-1!==e.indexOf("{");if(e!==r&&!n&&this.match(e,r))return r;if(e.endsWith(this.pathSeparatorPatternCache.getEndsOnWildCard()))return this.concat(e.substring(0,e.length-2),r);if(e.endsWith(this.pathSeparatorPatternCache.getEndsOnDoubleWildCard()))return this.concat(e,r);var i=e.indexOf("*.");if(n||-1===i||"."===this.pathSeparator)return this.concat(e,r);var a=e.substring(i+1),s=r.indexOf("."),h=-1===s?r:r.substring(0,s),o=-1===s?"":r.substring(s),u=".*"===a||0===a.length,c=".*"===o||0===o.length;if(!u&&!c)throw new Error("Cannot combine patterns: "+e+" vs "+r);return h+(u?o:a)},t.prototype.concat=function(t,e){var r=t.endsWith(this.pathSeparator),n=e.startsWith(this.pathSeparator);return r&&n?t+e.substring(1):r||n?t+e:t+this.pathSeparator+e},t.prototype.getPatternComparator=function(e){return new t.AntPatternComparator(e)},t.hasText=function(e){return null!=e&&!(0===e.length)&&t.containsText(e)},t.containsText=function(e){for(var r=e.length,n=0;n<r;n++)if(!t.isWhitespace(e.charAt(n)))return!0;return!1},t.tokenizeToStringArray=function(e,r,n,i){if(null==e)return t.EMPTY_STRING_ARRAY_$LI$();for(var a=e.split(r),s=[],h=0;h<a.length;h++){var o=a[h];n&&(o=o.trim()),(!i||o.length>0)&&s.push(o)}return s},t.isWhitespace=function(e){return t.WHITESPACE_$LI$().test(e)},t.DEFAULT_PATH_SEPARATOR="/",t.CACHE_TURNOFF_THRESHOLD=65536,t}();!function(t){var e=function(){function t(e,r){this.exactMatch=!1,this.pattern=null,this.variableNames=[],this.rawPattern=e,this.caseSensitive=r;for(var n,i="",a=0;null!=(n=t.GLOB_PATTERN_$LI$().exec(e));){i+=this.quote(e,a,n.index);var s=n[0];if("?"===s)i+=".";else if("*"===s)i+=".*";else if(s.startsWith("{")&&s.endsWith("}")){var h=s.indexOf(":");if(-1===h)i+=t.DEFAULT_VARIABLE_PATTERN,this.variableNames.push(n[1]);else{i=i+"("+s.substring(h+1,s.length-1)+")";var o=s.substring(1,h);this.variableNames.push(o)}}a=t.GLOB_PATTERN_$LI$().lastIndex}0===a?(this.exactMatch=!0,this.pattern=null):(this.exactMatch=!1,i+=this.quote(e,a,e.length),this.pattern=this.caseSensitive?new RegExp(i,"usg"):new RegExp(i,"iusg"))}return t.GLOB_PATTERN_$LI$=function(){return null==t.GLOB_PATTERN&&(t.GLOB_PATTERN=new RegExp("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}","g")),t.GLOB_PATTERN},t.prototype.quote=function(t,e,r){return e===r?"":t=(t=t.substring(e,r)).replace(/[[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},t.prototype.matchStrings=function(t,e){if(this.exactMatch)return this.caseSensitive?this.rawPattern===t:this.rawPattern.toUpperCase()===(null===t?t:t.toUpperCase());var r,n;if(null!=this.pattern&&(r=this.pattern,n=t,new RegExp("^"+r.source+"$",r.flags).test(n))){if(null!=e){var i=function(t){return new RegExp(t.source+"|").exec("").length-1}(this.pattern);if(this.variableNames.length!==i)throw new Error("The number of capturing groups in the pattern segment "+this.pattern+" does not match the number of URI template variables it defines, which can occur if capturing groups are used in a URI template regex. Use non-capturing groups instead.");for(var a=function(t,e){return new RegExp(t.source,t.flags).exec(e)}(this.pattern,t),s=1;s<=i;s++){var h=this.variableNames[s-1],o=a[s];e[h]=o}}return!0}return!1},t.DEFAULT_VARIABLE_PATTERN="(.*)",t}();t.AntPathStringMatcher=e;var r=function(){function t(t){this.path=t}return t.prototype.compare=function(e,r){var n=new t.PatternInfo(e),i=new t.PatternInfo(r);if(n.isLeastSpecific()&&i.isLeastSpecific())return 0;if(n.isLeastSpecific())return 1;if(i.isLeastSpecific())return-1;var a=e===this.path,s=r===this.path;return a&&s?0:a?-1:s?1:n.isPrefixPattern()&&i.isPrefixPattern()?i.getLength()-n.getLength():n.isPrefixPattern()&&0===i.getDoubleWildcards()?1:i.isPrefixPattern()&&0===n.getDoubleWildcards()?-1:n.getTotalCount()!==i.getTotalCount()?n.getTotalCount()-i.getTotalCount():n.getLength()!==i.getLength()?i.getLength()-n.getLength():n.getSingleWildcards()<i.getSingleWildcards()?-1:i.getSingleWildcards()<n.getSingleWildcards()?1:n.getUriVars()<i.getUriVars()?-1:i.getUriVars()<n.getUriVars()?1:0},t}();t.AntPatternComparator=r,function(e){var r=function(){function e(t){this.uriVars=0,this.singleWildcards=0,this.doubleWildcards=0,this.catchAllPattern=!1,this.prefixPattern=!1,this.length=null,this.pattern=t,null!=this.pattern&&(this.initCounters(),this.catchAllPattern="/**"===this.pattern,this.prefixPattern=!this.catchAllPattern&&this.pattern.endsWith("/**")),0===this.uriVars&&(this.length=null!=this.pattern?this.pattern.length:0)}return e.prototype.initCounters=function(){var t=0;if(null!=this.pattern)for(;t<this.pattern.length;)"{"===this.pattern.charAt(t)?(this.uriVars++,t++):"*"===this.pattern.charAt(t)?t+1<this.pattern.length&&"*"===this.pattern.charAt(t+1)?(this.doubleWildcards++,t+=2):t>0&&".*"!==this.pattern.substring(t-1)?(this.singleWildcards++,t++):t++:t++},e.prototype.getUriVars=function(){return this.uriVars},e.prototype.getSingleWildcards=function(){return this.singleWildcards},e.prototype.getDoubleWildcards=function(){return this.doubleWildcards},e.prototype.isLeastSpecific=function(){return null==this.pattern||this.catchAllPattern},e.prototype.isPrefixPattern=function(){return this.prefixPattern},e.prototype.getTotalCount=function(){return this.uriVars+this.singleWildcards+2*this.doubleWildcards},e.prototype.getLength=function(){return null==this.length&&(this.length=null!=this.pattern?this.pattern.replace(t.VARIABLE_PATTERN_$LI$(),"#").length:0),this.length},e}();e.PatternInfo=r}(r=t.AntPatternComparator);var n=function(){function t(t){this.endsOnWildCard=t+"*",this.endsOnDoubleWildCard=t+"**"}return t.prototype.getEndsOnWildCard=function(){return this.endsOnWildCard},t.prototype.getEndsOnDoubleWildCard=function(){return this.endsOnDoubleWildCard},t}();t.PathSeparatorPatternCache=n}(r);const n=r;return e.default})()}));

@@ -0,0 +0,0 @@ module.exports = {

{
"name": "@howiefh/ant-path-matcher",
"version": "0.0.1",
"version": "0.0.2",
"description": "Ant Path Matcher",

@@ -5,0 +5,0 @@ "main": "dist/ant-path-matcher.js",

@@ -0,0 +0,0 @@ An implementation for Ant-style path patterns.

@@ -0,0 +0,0 @@ /**

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

// var AntPathMatcher = require('../dist/ant-path-matcher');
// var AntPathMatcher = require('../src/index');
import AntPathMatcher from "../src/index";

@@ -4,0 +2,0 @@

@@ -9,3 +9,3 @@ const path = require('path');

filename: 'ant-path-matcher.js',
globalObject: 'this',
globalObject: 'typeof self !== \'undefined\' ? self : this',
library: {

@@ -12,0 +12,0 @@ name: 'AntPathMatcher',

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