-
Notifications
You must be signed in to change notification settings - Fork 14
Use fetch
infrastructure to fetch source maps
#27
Conversation
source-map.bs
Outdated
1. Let |request| be a new [=request=] whose [=request/URL=] is |url|. | ||
1. [=Fetch=] |request| with [=processResponseConsumeBody=] set to the following steps given [=response=] <var ignore>response</var> and null, failure, or a [=byte sequence=] |bodyBytes|: | ||
1. If |bodyBytes| is null or failure, [=reject=] |promise| with a {{TypeError}} and abort these steps. | ||
1. Let |sourceMap| be the result of [=parsing JSON bytes to a JavaScript value=] given |bodyBytes|. |
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.
This is basically JSON.parse(utf8decode(bodyBytes))
. There is also the option of returning an "internal spec value" rather than a JS object, but our spec is so high level that it doesn't really matter.
Oh I should also merge http://localhost:4507/source-map.html#json-over-http-transport in this section |
source-map.bs
Outdated
1. If |url|'s [=url/scheme=] is "<code>http</code>" and |bodyBytes| [=byte sequence/starts with=] \`<code>)]}'</code>\`, then: | ||
1. [=While=] |bodyBytes|'s [=byte sequence/length=] is not 0 and |bodyBytes|'s 0th byte is not 0x0A (LF) or 0x0D (CR): | ||
1. remove the 0th byte from |bodyBytes|. |
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 we know if this is only for HTTP or also for HTTPS?(answer by @jridgewell: yes)- Do we know what "ignore the first line" means? Some possible sets of line terminators are:
\n
and\r
(what HTTP defines as line terminators)\n
,\r
, U+2028, U+2029 (what JS defines as line terminators)
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.
Does anyone have bandwidth to test this in some browsers?
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.
According to https://developer.chrome.com/blog/sourcemaps#potential_xssi_issues, the answer could also be "just \n"
Closes tc39/ecma426#30
This PR uses the
fetch
spec to fetch source maps, relieving us from a couple responsibility: