From fe840d26dfbcac7ccc3802c7b3f837b82291c152 Mon Sep 17 00:00:00 2001 From: Alexandr Zelenin Date: Fri, 18 Dec 2015 08:05:17 +0200 Subject: [PATCH] Added check data match RegExp part of resolve method --- lib/url.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/url.js b/lib/url.js index b8538e6..bb6b9ff 100644 --- a/lib/url.js +++ b/lib/url.js @@ -333,6 +333,13 @@ Url.prototype.resolve = function (params, options) { } value = _.isFunction(value) ? value.call(params) : value; + + if (capture && !(new RegExp('^' + capture + '$')).test(value)) { + throw new Error( + 'Value "' + value + + '" does not math regexp ' + '(^' + capture + '$)'); + } + var escapedValue = _.map(String(value).split('/'), function (segment) { return encodeURIComponent(segment); }).join('/');