export const attachOpenInEditor = (stack: string) => { const lines = stack.split("\n") return lines.map((line) => { // A line like this: at App (http://localhost:5173/src/App.tsx?t=1720527056591:41:9) // Find the `localhost` part and open the file in the editor if (!line.includes("at ")) { return line } const match = line.match(/(http:\/\/localhost:\d+\/[^:]+):(\d+):(\d+)/) if (match) { const [o] = match // Find `@fs/` // Like: `http://localhost:5173/@fs/Users/innei/git/work/rss3/follow/node_modules/.vite/deps/chunk-RPCDYKBN.js?v=757920f2:11548:26` const realFsPath = o.split("@fs")[1] if (realFsPath) { return ( // Delete `v=` hash, like `v=757920f2`