(content: string)
| 212 | } |
| 213 | |
| 214 | export function parseSourceMappingUrl(content: string): string | undefined { |
| 215 | if (!content) return; |
| 216 | const name = 'sourceMappingURL'; |
| 217 | const length = content.length; |
| 218 | const nameLength = name.length; |
| 219 | |
| 220 | let pos = length; |
| 221 | let equalSignPos = 0; |
| 222 | while (true) { |
| 223 | pos = content.lastIndexOf(name, pos); |
| 224 | if (pos === -1) return; |
| 225 | // Check for a /\/[\/*][@#][ \t]/ regexp (length of 4) before found name. |
| 226 | if (pos < 4) return; |
| 227 | pos -= 4; |
| 228 | if (content[pos] !== '/') continue; |
| 229 | if (content[pos + 1] !== '/') continue; |
| 230 | if (content[pos + 2] !== '#' && content[pos + 2] !== '@') continue; |
| 231 | if (content[pos + 3] !== ' ' && content[pos + 3] !== '\t') continue; |
| 232 | equalSignPos = pos + 4 + nameLength; |
| 233 | if (equalSignPos < length && content[equalSignPos] !== '=') continue; |
| 234 | break; |
| 235 | } |
| 236 | |
| 237 | let sourceMapUrl = content.substring(equalSignPos + 1); |
| 238 | const newLine = sourceMapUrl.indexOf('\n'); |
| 239 | if (newLine !== -1) sourceMapUrl = sourceMapUrl.substring(0, newLine); |
| 240 | sourceMapUrl = sourceMapUrl.trim(); |
| 241 | for (let i = 0; i < sourceMapUrl.length; ++i) { |
| 242 | if ( |
| 243 | sourceMapUrl[i] === '"' || |
| 244 | sourceMapUrl[i] === "'" || |
| 245 | sourceMapUrl[i] === ' ' || |
| 246 | sourceMapUrl[i] === '\t' |
| 247 | ) |
| 248 | return; |
| 249 | } |
| 250 | return sourceMapUrl; |
| 251 | } |
| 252 | |
| 253 | export async function checkContentHash( |
| 254 | absolutePath: string, |
no test coverage detected