Normalize hook default Web behaviour

# Ian Hickson (11 years ago)

Hello again,

I'm looking at what the default behaviour of the Web's normalize hook should be. I've read through the links people have posted about this before, e.g. [1], but they tend to focus on the behaviour for sensible inputs and ES6-only inputs, so I'm not sure the following cases are really covered by those.

The first case is around normalization vs location. Suppose a page has this markup:

<base href="example.com"> <script type=module href="example.com/foo.js"></script> <script type=module> import "foo"; </script>

Do we want foo.js to be downloaded and executed once, or twice?

Second case:

import "test/";

What should that do:

throw in the normalize hook? import the file at "example.com/test.js"? import the file at "example.com/test/.js"? import the file at "example.com/test/default.js"?

Third case: empty string. What should get imported, if anything, if you do something like this?:

import "";

Fourth case: Suppose the referrer name is "foo/bar", the base URL is "example.com/baz", and a module tries to import "../../../quux".

What should get imported?

"example.com/baz/quux.js", because you only apply the "../" resolution to the referrer name, and trim leading "../"s.

"example.com/quux.js", because you apply the "../" resolution to the referrer name and the base URL, and trim leading "../"s.

nothing, throw an exception because the ".."s go beyond the referrer name's root.

nothing, throw an exception because the ".."s go beyond the domain root when normalised.

[1] dherman/web-modules/blob/master/browser-loader/requirements.md