Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for strict parameter matching #1

Closed
fczbkk opened this issue Nov 24, 2015 · 0 comments
Closed

Add option for strict parameter matching #1

fczbkk opened this issue Nov 24, 2015 · 0 comments
Assignees

Comments

@fczbkk
Copy link
Owner

fczbkk commented Nov 24, 2015

There should be an option to set strict param matching. For example I want a pettern that will match ?aaa=bbb but not ?aaa=bbb&ccc=ddd. The loose param mathcing should be the default option, because that's what you want in most cases. But there should be a way to switch. Like this:

var loose_matcher = new UrlMatch('*://*/*?aaa=bbb');
var strict_matcher = new UrlMatch('*://*/*?aaa=bbb', {strict_param_matching: true});

var simple_url = 'http://inlinemanual.com/?aaa=bbb';
loose_matcher.test(simple_url);  // true
strict_matcher.test(simple_url);  // true

var complex_url = 'http://inlinemanual.com/?aaa=bbb&ccc=ddd';
loose_matcher.test(complex_url);  // true
strict_matcher.test(complex_url);  // false

Then we can add a simple switch (e.g. ?!) to the pattern, that will allow this:

// this...
new UrlMatch('*://*/*?aaa=bbb', {strict_param_matching: true});
// ...should be identical to this
new UrlMatch('*://*/*?!aaa=bbb');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant