function extractStackAt
extractStackAt(stack: string | null | undefined): string | null

Extracts the source location from a stack trace string. Supports Chrome/Node style "at func (url:line:col)" and Firefox/WebKit style "@url:line:col". Returns a clean location string without surrounding parens, or null if nothing can be extracted.

extractStackAt('    at add (http://localhost:1234/tests.js:10:15)'); // 'http://localhost:1234/tests.js:10:15'
extractStackAt('add@http://localhost:1234/tests.js:10:15'); // same frame, Firefox/WebKit style
extractStackAt('no location here'); // null

Parameters

stack: string | null | undefined

Return Type

string | null

Usage

import { extractStackAt } from "lib/reporters/failure.ts";