-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[bugfix] handle multi ? urls #748
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,13 +203,13 @@ describe('lib/http-proxy/common.js', function () { | |
expect(outgoing.path).to.eql('/forward/static/path'); | ||
}) | ||
|
||
it('should not modify the query string', function () { | ||
it.only('should not modify the query string', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be set to only so we run all the tests ;). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooops |
||
var outgoing = {}; | ||
common.setupOutgoing(outgoing, { | ||
target: { path: '/forward' }, | ||
}, { url: '/?foo=bar//&target=http://foobar.com/' }); | ||
}, { url: '/?foo=bar//&target=http://foobar.com/?a=1%26b=2&other=2' }); | ||
|
||
expect(outgoing.path).to.eql('/forward/?foo=bar//&target=http://foobar.com/'); | ||
expect(outgoing.path).to.eql('/forward/?foo=bar//&target=http://foobar.com/?a=1%26b=2&other=2'); | ||
}) | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
retSegs.push.apply(retSegs, lastSegs);
as that modifies theretSegs
array. Concat returns a new array and we want to prevent new array creation. This should also fix the test from failing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you confirm the code is correct? o?o
I think, the code
retSegs.concat(lastSegs)
doesn't seemingly change the arrayretSegs
value when it doesn't assigned toretSegs
likeretSegs = retSegs.concat(lastSegs);
, so wouldn't theretSegs
value in the last statementreturn retSegs.join('?')
be original? You can try by a multiple '?' urls.The codes recommended:
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it doesnt create a new array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use 'concat' can create a new array indeed, but why to need a new array? And that, the new array isn't used by you to the codes after it. So, the variable
retSegs
value in return statement is still the old value, that is to say, the array length of the variableretSegs
is still 1.If you want to use 'concat' function, an assignment statement is required, like
retSegs = retSegs.concat(lastSegs)
, because of the example below.So, I think that the code
retSegs.concat(lastSegs)
should be changed toretSegs = retSegs.concat(lastSegs)
. Do you?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand there is a bit of a language barrier here but the code should be...
We DO NOT want to create a new array. I understand how concat works which is why I do not want to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see now, and the codes in master are already right.
I just had doubts when I saw the codes in the branch http-proxy/common.js#L160 from #748 are below:
So sorry! ^-^!