We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This line:
this.path = path.replace(pageBase, '') || '/'
changes the path incorrectly by replacing (removing) the pageBase - first occurrence. It should remove the most left only, if there is any.
path
pageBase
For example,
var pageBase = "/"; var path = "my/route/"; path.replace(pageBase, ''); // ——» produces "myroute/"
We need to escape regexp characters within pageBase:
function escapeRegExp(s) { return s.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1') }
Then change the buggy line with:
// we'll ensure it only matches the start of the string. var re = new RegExp('^' + escapeRegExp(pageBase)); this.path = path.replace(re, '') || '/';
The text was updated successfully, but these errors were encountered:
fix visionmedia#526
2c54601
- Added escapeRegExp() function - Updated Context constructor
Merge pull request #527 from onury/fix-path
3229c22
fix #526
No branches or pull requests
Problem
This line:
changes the
path
incorrectly by replacing (removing) thepageBase
- first occurrence.It should remove the most left only, if there is any.
For example,
Solution
We need to escape regexp characters within pageBase:
Then change the buggy line with:
The text was updated successfully, but these errors were encountered: