Skip to content

path can be empty string#110

Merged
chimurai merged 2 commits into
chimurai:masterfrom
sunnylqm:patch-1
Sep 20, 2016
Merged

path can be empty string#110
chimurai merged 2 commits into
chimurai:masterfrom
sunnylqm:patch-1

Conversation

@sunnylqm

Copy link
Copy Markdown
Contributor

No description provided.

@coveralls

coveralls commented Sep 11, 2016

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 96.875% when pulling a3cdd94 on sunnylqm:patch-1 into 7d1865c on chimurai:master.

@chimurai

Copy link
Copy Markdown
Owner

Please provide a description and test plan for this PR.

@sunnylqm

Copy link
Copy Markdown
Contributor Author

@chimurai for example

{
        path: '/proxy',
        target: 'http:/example.com',
        pathRewrite: () => ''
}

If I want to replace the whole path into an empty string, then it would complain "No rewritten path found"

Comment thread lib/index.js Outdated
var path = pathRewriter(req.url, req);

if (path) {
if (path !== false) {

@chimurai chimurai Sep 12, 2016

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the condition to:

if (typeof path === 'string') {
   ...
}

@chimurai

chimurai commented Sep 12, 2016

Copy link
Copy Markdown
Owner

Testing for a string should be safer.
This will better cope with 'garbage' returned by custom functions...
(Array's, Objects, undefined, etc...)

@coveralls

coveralls commented Sep 13, 2016

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 96.875% when pulling f597c1d on sunnylqm:patch-1 into 7d1865c on chimurai:master.

@sunnylqm

Copy link
Copy Markdown
Contributor Author

Can it be merged now @chimurai

@chimurai
chimurai merged commit 0cb6839 into chimurai:master Sep 20, 2016
@chimurai

Copy link
Copy Markdown
Owner

Sorry for the late response.
Thanks for contributing!

@sunnylqm
sunnylqm deleted the patch-1 branch September 21, 2016 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants