* Resolves source map payload data from the source url and source map url. * If the source map url is a data url, the data is returned. * Otherwise the source map url is resolved to a file path and the file is read. * @param {string} sourceURL - url of the source file * @param {string} sourceMap
(sourceURL, sourceMappingURL)
| 235 | * @returns {object} deserialized source map JSON object |
| 236 | */ |
| 237 | function dataFromUrl(sourceURL, sourceMappingURL) { |
| 238 | const url = URLParse(sourceMappingURL); |
| 239 | |
| 240 | if (url != null) { |
| 241 | switch (url.protocol) { |
| 242 | case 'data:': |
| 243 | return sourceMapFromDataUrl(sourceURL, url.pathname); |
| 244 | default: |
| 245 | debug(`unknown protocol ${url.protocol}`); |
| 246 | return null; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | const mapURL = URLParse(sourceMappingURL, sourceURL); |
| 251 | if (mapURL === null) { |
| 252 | return null; |
| 253 | } |
| 254 | return sourceMapFromFile(mapURL); |
| 255 | } |
| 256 | |
| 257 | // Cache the length of each line in the file that a source map was extracted |
| 258 | // from. This allows translation from byte offset V8 coverage reports, |
no test coverage detected
searching dependent graphs…