diff --git a/package.json b/package.json index afcba22..e183f69 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "webpack": "^1.13.0" }, "dependencies": { + "array-reduce-prototypejs-fix": "^1.0.0", "babel-plugin-transform-es2015-classes": "^6.8.0" } } diff --git a/src/params.js b/src/params.js index 7e05a19..86f3ead 100644 --- a/src/params.js +++ b/src/params.js @@ -1,5 +1,6 @@ import UrlPart from './url-part'; import exists from './utilities/exists'; +import arrayReduce from 'array-reduce-prototypejs-fix'; export default class extends UrlPart { @@ -67,7 +68,7 @@ export default class extends UrlPart { if (exists(patterns)) { - result = patterns.reduce((previous_result, pattern) => { + result = arrayReduce(patterns, (previous_result, pattern) => { const re = new RegExp('(^|\&)' + pattern + '(\&|$)'); return previous_result && re.test(content); }, result); @@ -79,7 +80,7 @@ export default class extends UrlPart { .join('|'); const re = new RegExp('(^|\&)(' + wrapped_patterns + ')(\&|$)'); - result = content.split('&').reduce((previous_result, pair) => { + result = arrayReduce(content.split('&'), (previous_result, pair) => { return previous_result && re.test(pair); }, result); } else {