MCPcopy Create free account
hub / github.com/benjitaylor/agentation / cleanSourcePath

Function cleanSourcePath

package/src/utils/source-location.ts:534–567  ·  view source on GitHub ↗

* Strip bundler URL prefixes from a raw source path.

(rawPath: string)

Source from the content-addressed store, hash-verified

532 * Strip bundler URL prefixes from a raw source path.
533 */
534function cleanSourcePath(rawPath: string): string {
535 let path = rawPath;
536
537 // 1. Strip query params and hashes
538 path = path.replace(/[?#].*$/, "");
539
540 // 2. Turbopack project prefix
541 path = path.replace(/^turbopack:\/\/\/\[project\]\//, "");
542
543 // 3. webpack-internal
544 path = path.replace(/^webpack-internal:\/\/\/\.\//, "");
545 path = path.replace(/^webpack-internal:\/\/\//, "");
546
547 // 4. webpack
548 path = path.replace(/^webpack:\/\/\/\.\//, "");
549 path = path.replace(/^webpack:\/\/\//, "");
550
551 // 5. turbopack generic
552 path = path.replace(/^turbopack:\/\/\//, "");
553
554 // 6. http(s)://host:port/
555 path = path.replace(/^https?:\/\/[^/]+\//, "");
556
557 // 7. file:///
558 path = path.replace(/^file:\/\/\//, "/");
559
560 // 8. Webpack chunk group prefixes like (app-pages-browser)/./
561 path = path.replace(/^\([^)]+\)\/\.\//, "");
562
563 // 9. Leading ./
564 path = path.replace(/^\.\//, "");
565
566 return path;
567}
568
569/**
570 * Probe a single fiber's component function by invoking it with a

Callers 1

probeComponentSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…