Skip to content
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

URL: Fix resolving from non-file to file URLs. #1277

Closed
wants to merge 1 commit into from

Conversation

jagoda
Copy link
Contributor

@jagoda jagoda commented Mar 26, 2015

When resolving a reference URL with the 'file' scheme an no host
against a base URL without the 'file' scheme, the first path element
of the reference URL is used as the host for the target URL. This
results in an invalid target URL.

This change makes an exception for file URLs so that the host is not
mangled during URL resolution.

@@ -495,7 +495,7 @@ Url.prototype.resolveObject = function(relative) {
}

result.protocol = relative.protocol;
if (!relative.host && !hostlessProtocol[relative.protocol]) {
if (!relative.host && !/file:?/.test(relative.protocol) && !hostlessProtocol[relative.protocol]) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the regex match the whole string?

Style: long line, please wrap at 80 columns (one clause per line.)

@mscdex mscdex added the url Issues and PRs related to the legacy built-in url module. label Mar 26, 2015
When resolving a reference URL with the 'file' scheme an no host
against a base URL without the 'file' scheme, the first path element
of the reference URL is used as the host for the target URL. This
results in an invalid target URL.

This change makes an exception for file URLs so that the host is not
mangled during URL resolution.
@jagoda
Copy link
Contributor Author

jagoda commented Mar 27, 2015

Thanks for the feedback. I believe I have addressed the style concerns. Is there anything else that I need to do?

@bnoordhuis bnoordhuis added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 27, 2015
@bnoordhuis
Copy link
Member

I'm tagging this semver-minor because I expect that's what it is. Someone else should do the final sign-off and land it.

@bnoordhuis
Copy link
Member

Ping @iojs/collaborators.

@silverwind
Copy link
Contributor

@petkaantonov are you saying the current output is correct/more desireable in your comment above?

@petkaantonov
Copy link
Contributor

@silverwind No I am saying the new output is correct, on top of that I am saying that current output is almost always incorrect in whatwg tests

@silverwind
Copy link
Contributor

In that case, LGTM

@petkaantonov
Copy link
Contributor

@bnoordhuis Shouldn't this either be a patch or a major? I don't see how it could be a minor

@bnoordhuis
Copy link
Member

@petkaantonov I guess it's not. I'll remove the label.

@bnoordhuis bnoordhuis removed the semver-minor PRs that contain new features and should be released in the next minor version. label Apr 4, 2015
petkaantonov pushed a commit that referenced this pull request Apr 4, 2015
When resolving a reference URL with the 'file' scheme an no host
against a base URL without the 'file' scheme, the first path element
of the reference URL is used as the host for the target URL. This
results in an invalid target URL.

This change makes an exception for file URLs so that the host is not
mangled during URL resolution.

PR-URL: #1277
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
@petkaantonov
Copy link
Contributor

landed in 1e94057

@jagoda
Copy link
Contributor Author

jagoda commented Apr 6, 2015

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
url Issues and PRs related to the legacy built-in url module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants