* Extract source mapping URL from code comments * @param {string} code source code content * @returns {SourceMappingURL} source mapping information
(code)
| 46 | * @returns {SourceMappingURL} source mapping information |
| 47 | */ |
| 48 | function getSourceMappingURL(code) { |
| 49 | const lines = code.split(/^/m); |
| 50 | /** @type {RegExpMatchArray | null | undefined} */ |
| 51 | let match; |
| 52 | |
| 53 | for (let i = lines.length - 1; i >= 0; i--) { |
| 54 | match = lines[i].match(sourceMappingURLRegex); |
| 55 | if (match) { |
| 56 | break; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | const sourceMappingURL = match ? match[1] || match[2] || "" : ""; |
| 61 | |
| 62 | return { |
| 63 | sourceMappingURL: sourceMappingURL |
| 64 | ? decodeURI(sourceMappingURL) |
| 65 | : sourceMappingURL, |
| 66 | replacementString: match ? match[0] : "" |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get absolute path for source file |
no test coverage detected