-
Notifications
You must be signed in to change notification settings - Fork 755
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
Proxy regexp too aggressive #138
Comments
Oh yeah - good catch! In the spirit of trying encourage more contributors, would you like to make a PR with some failing tests? (and a fix, if you can). As a pointer, in // run 'npm test' to see everything still passes
// This will pass
it("should use the regex to replace links", function () {
var rewrite = utils.rewriteLinks({host: "example.com", port: 80}, proxyUrl);
var actual = "<a href='http://example.com'></a>".replace(rewrite.match, rewrite.fn);
var expected = "<a href='http://192.168.0.4:3002'></a>";
assert.equal(actual, expected);
}); And then to replicate your issue, something like this should cause it to fail // This will fail - time to fix
it("should use the regex to replace links", function () {
var rewrite = utils.rewriteLinks({host: "example.com", port: 80}, proxyUrl);
var actual = "<a href='http://example.com/sites/example.com/about'></a>".replace(rewrite.match, rewrite.fn);
var expected = "<a href='http://192.168.0.4:3002/sites/example.com/about'></a>";
assert.equal(actual, expected);
}); To run the tests, just fork the repo, clone it locally to your machine, run Let me know if you have any problems, or if you would rather not help out :) |
Ok, cool. I might need a few weeks to get onto this, but I'll give it a shot. |
I have this so far - seems to work, but seems to complicated |
fixed in 0.8.1 :) |
I'm having issues with urls that look like http://example.com/sites/example.com/theme/style.css being rewritten to http://192.168.0.24:3002/sites/192.168.0.24:3002/theme/style.css
In proxy.js utils.rewriteLinks is using a global regular expression match. Can we make this just stop after the first match please?
The text was updated successfully, but these errors were encountered: