* Returns a pretty name for the script. This is the name displayed in * stack traces and returned through DAP if the file does not verifiably * exist on disk.
()
| 305 | * exist on disk. |
| 306 | */ |
| 307 | private _fullyQualifiedName(): string { |
| 308 | if (!this.url) { |
| 309 | return '<eval>/VM' + this._sourceReference; |
| 310 | } |
| 311 | |
| 312 | if (this._absolutePath.startsWith('<node_internals>')) { |
| 313 | return this._absolutePath; |
| 314 | } |
| 315 | |
| 316 | if (utils.isAbsolute(this.url)) { |
| 317 | return this.url; |
| 318 | } |
| 319 | |
| 320 | const parsedAbsolute = utils.fileUrlToAbsolutePath(this.url); |
| 321 | if (parsedAbsolute) { |
| 322 | return parsedAbsolute; |
| 323 | } |
| 324 | |
| 325 | let fqname = this.url; |
| 326 | try { |
| 327 | const tokens: string[] = []; |
| 328 | const url = new URL(this.url); |
| 329 | if (url.protocol === 'data:') { |
| 330 | return '<eval>/VM' + this._sourceReference; |
| 331 | } |
| 332 | |
| 333 | if (url.hostname) { |
| 334 | tokens.push(url.hostname); |
| 335 | } |
| 336 | |
| 337 | if (url.port) { |
| 338 | tokens.push('\uA789' + url.port); // : in unicode |
| 339 | } |
| 340 | |
| 341 | if (url.pathname) { |
| 342 | tokens.push(/^\/[a-z]:/.test(url.pathname) ? url.pathname.slice(1) : url.pathname); |
| 343 | } |
| 344 | |
| 345 | if (url.searchParams) { |
| 346 | tokens.push(url.searchParams.toString()); |
| 347 | } |
| 348 | |
| 349 | fqname = tokens.join(''); |
| 350 | } catch (e) { |
| 351 | // ignored |
| 352 | } |
| 353 | |
| 354 | if (fqname.endsWith('/')) { |
| 355 | fqname += '(index)'; |
| 356 | } |
| 357 | |
| 358 | if (this.inlineScriptOffset) { |
| 359 | fqname += `\uA789${this.inlineScriptOffset.lineOffset + 1}:${ |
| 360 | this.inlineScriptOffset.columnOffset + 1 |
| 361 | }`; |
| 362 | } |
| 363 | return fqname; |
| 364 | } |
no test coverage detected