-
Notifications
You must be signed in to change notification settings - Fork 363
Use standard-conforming URL #360
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
Conversation
The issues metioned in #275 (comment) are not checked yet. I.e. whether these two cases are intentional: assert.equal(libUtil.join('http://foo.org/a//', '//b'), 'http://b');
assert.equal(libUtil.join('http://www.example.com', '//foo.org/bar'), 'http://foo.org/bar'); By the way, I made another branch based on 0.6.1 to test in debugger.html, which make one test case fail: devtools-source-map/src/tests/source-map.js line 29: expect |
About the CI failure... it is caused by an inconsistency between webpack and webpack-cli. I filed #361 to fix it. |
If the global "URL" is a function, use it. This should be the case in browser environments. In [node] environment, `require('url').URL`, which follows WHATWG URL Standard, was added in v7, and `URL` became available in global object since v10.0. To support the version before v10, we need to check the global object, and then fallback to `require('url').URL`. However, note one thing: the version packed in by webpack-v3 ([npm-url]) only supports the "legacy version of Url API", which is not compatible with "WHATWG URL Standard", must not be used as a replacement for `URL`. [node]: https://nodejs.org/dist/latest-v10.x/docs/api/url.html [npm-url]: https://www.npmjs.com/package/url
c301f2d
to
e4c4e7b
Compare
Pull Request Test Coverage Report for Build 512
💛 - Coveralls |
@redeyes2015 FYI, I posted #367 with a more elaborate approach to using |
@loganfsmyth : Before closing this PR, I still feel like to ask, if I may, you to consider this test case: exports["test sourceURL resolution with null sourceRoot and blob sourceMapURL"] = async function(assert) {
const map = {
version: 3,
sources: ["something.js"],
names: [],
mappings: "CAAS",
file: "static/js/manifest.b7cf97680f7a50fa150f.js",
sourceRoot: null,
};
const consumer = await new SourceMapConsumer(map, "blob:http://exmaple.com/12345-12345-12345");
assert.equal(consumer.sources.length, 1);
assert.equal(consumer.sources[0], "something.js");
consumer.destroy();
}; AFAIK, this still fails in #367. One way to fix this is adding try-catch guards, like the last part of #275 (comment) . The aternative would be avoiding passing "blob url" as SourceMapUrl in async function createConsumer(map: any, sourceMapUrl: any): SourceMapConsumer {
+ if (typeof sourceMapUrl == 'string' && sourceMapUrl.startsWith('blob:')) {
+ sourceMapUrl = undefined;
+ }
return new SourceMapConsumer(map, sourceMapUrl);
} Either way would solve the issue for style-loader, but both feel hacky. I just hope this would be handled eventually. Thanks for all the response and support :-) |
Initial work is done by @tromey.
A commit is added so that when
URL
is presented in global object, it is used asthe consturctor; otherwise fallback to use
require('url').URL
in order to supportthe environments of node v8 and v9. Since node v10,
URL
is also presented inglobal object.