Reputation: 21
I am working with sails 0.11.2. Here i am facing an issue with defining a route pattern that will start with '/source/< anything goes here>/< must not contain .js extension at the end>'
Regular Expression : /^\/source.*(?<!.js)$/i
in java script in working fine, but when i am putting this in sails route.
Getting Error : Invalid regular expression: /^r|\/^\/source\.(.*)(?<!\.js)$\/i\/?$/: Invalid group
.
Syntax in Route :
'r|/^\/source.*(?<!.js)$/i' : {
controller: 'pageController',
action: 'pageAction'
}
Please help me out, what is wrong and how to correct it?
Upvotes: 2
Views: 334
Reputation: 502
Javascript doesn't support lookbehind (?<!)
instead you can use negative lookahead (?!)
also the /.../i
part shouldn't be in the regex string
so the valid expression should be :
^\/source(.(?!\\.js$))*$
Upvotes: 2