You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 24, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: source-map-rev3.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ May 2, 2012 | John Lenz | HTTP header and CC-BY-SA license
20
20
July 30, 2012 | John Lenz | Modified recommended HTTP header name.
21
21
August 20, 2012 | John Lenz | Add CSS linkage recommendation
22
22
October 24, 2012 | John Lenz | Add clarifying section on source locations.
23
+
February 19, 2013 | John Lenz | Add “sourcesContent” line to support self contained source maps.<p>Added note regarding using data uri to load source maps.
23
24
24
25
## License
25
26
@@ -65,9 +66,10 @@ Source Mapping URL | The URL referencing the location of a source map from the g
65
66
3.`file: "out.js",`
66
67
4.`sourceRoot : "",`
67
68
5.`sources: ["foo.js", "bar.js"],`
68
-
6.`names: ["src", "maps", "are", "fun"],`
69
-
7.`mappings: "AA,AB;;ABCDE;"`
70
-
8.`}`
69
+
6.`sourcesContent: [null, null],`
70
+
7.`names: ["src", "maps", "are", "fun"],`
71
+
8.`mappings: "AA,AB;;ABCDE;"`
72
+
9.`}`
71
73
72
74
Line 1: The entire file is a single JSON object
73
75
@@ -79,9 +81,11 @@ Line 4: An optional source root, useful for relocating source files on a server
79
81
80
82
Line 5: A list of original sources used by the “mappings” entry.
81
83
82
-
Line 6: A list of symbol names used by the “mappings” entry.
84
+
Line 6: An optional list of source content, useful when the “source” can’t be hosted. The contents are listed in the same order as the sources in line 5. “null” may be used of some original sources should be retrieved by name.
83
85
84
-
Line 7: A string with the encoded mapping data.
86
+
Line 7: A list of symbol names used by the “mappings” entry.
87
+
88
+
Line 8: A string with the encoded mapping data.
85
89
86
90
The “mappings” data is broken down as follows:
87
91
@@ -223,6 +227,8 @@ This recommendation works well for JavaScript, it is expected that other source
223
227
224
228
Note: <url> is a URL as defined in RFC3986; in particular, characters outside the set permitted to appear in URIs must be percent-encoded.
225
229
230
+
Note: <url> maybe a data URI. Using a data URI along with “sourcesContent” allow for a completely self-contained source-map.
231
+
226
232
Regardless of the method used to retrieve the source mapping URL the same process is used to resolve it, which is as follows:
227
233
228
234
When the source mapping URL is not absolute, then it is relative to the generated code’s “source origin”. The source origin is determined by one of the following cases:
@@ -264,6 +270,6 @@ However, It is unclear what a “source map reference” looks like in anything
264
270
265
271
### JSON over HTTP Transport
266
272
267
-
[XSSI](http://googleonlinesecurity.blogspot.com/2011/05/website-security-for-webmasters.html) attacks <spanstyle="text-decoration:underline;">(https://wiki.corp.google.com/twiki/bin/view/Main/ISETeamScriptInclusion)</span> could potentially make source maps available to attackers by doing a direct script src to a source map after overriding the Array constructor. This can be effectively prevented by preprending a JavaScript syntax error to the start of the response.
273
+
[XSSI](http://googleonlinesecurity.blogspot.com/2011/05/website-security-for-webmasters.html) attacks could potentially make source maps available to attackers by doing a direct script src to a source map after overriding the Array constructor. This can be effectively prevented by preprending a JavaScript syntax error to the start of the response.
268
274
269
275
Thus when delivering source maps over HTTP, servers may prepend a line starting with the string “)]}'” to the sourcemap. If the response starts with this string clients must ignore the first line.
0 commit comments