(sourceURL, url)
| 296 | // data:[<mediatype>][;base64],<data> see: |
| 297 | // https://tools.ietf.org/html/rfc2397#section-2 |
| 298 | function sourceMapFromDataUrl(sourceURL, url) { |
| 299 | const { 0: format, 1: data } = StringPrototypeSplit(url, ',', 2); |
| 300 | const splitFormat = StringPrototypeSplit(format, ';'); |
| 301 | const contentType = splitFormat[0]; |
| 302 | const base64 = splitFormat[splitFormat.length - 1] === 'base64'; |
| 303 | if (contentType === 'application/json') { |
| 304 | const decodedData = base64 ? |
| 305 | Buffer.from(data, 'base64').toString('utf8') : data; |
| 306 | try { |
| 307 | const parsedData = JSONParse(decodedData); |
| 308 | return sourcesToAbsolute(sourceURL, parsedData); |
| 309 | } catch (err) { |
| 310 | // TODO(legendecas): warn about invalid source map JSON string. |
| 311 | // But it could be verbose. |
| 312 | debug(err); |
| 313 | return null; |
| 314 | } |
| 315 | } else { |
| 316 | debug(`unknown content-type ${contentType}`); |
| 317 | return null; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // If the sources are not absolute URLs after prepending of the "sourceRoot", |
| 322 | // the sources are resolved relative to the SourceMap (like resolving script |
no test coverage detected
searching dependent graphs…