Skip to content

Commit

Permalink
Don't assume a React environment name matches \w+
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Oct 11, 2024
1 parent 8f09588 commit 499327c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ export function getOriginalStackFrames(
}

const webpackRegExes = [
/^(rsc:\/\/React\/\w+\/)?webpack-internal:\/\/\/(\.)?(\((\w+)\))?/,
/^(rsc:\/\/React\/[^/]+\/)?webpack-internal:\/\/\/(\.)?(\((\w+)\))?/,
/^(webpack:\/\/\/(\.)?|webpack:\/\/(_N_E\/)?)(\((\w+)\))?/,
]

const replacementRegExes = [
/^(rsc:\/\/React\/\w+\/)/,
/^(rsc:\/\/React\/[^/]+\/)/,
/^webpack-internal:\/\/\/(\.)?(\((\w+)\))?/,
/^(webpack:\/\/\/(\.)?|webpack:\/\/(_N_E\/)?)(\((\w+)\))?/,
/\?\d+$/, // React's fakeFunctionIdx query param
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function createStackFrame(searchParams: URLSearchParams) {

// rsc://React/Server/file://<filename>?42 => file://<filename>
const file = fileParam
.replace(/^rsc:\/\/React\/\w+\//, '')
.replace(/^rsc:\/\/React\/[^/]+\//, '')
.replace(/\?\d+$/, '')

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export async function getSource(
// webpack://_N_E/./src/hello.tsx => ./src/hello.tsx
const moduleId = filename
.replace(
/^(rsc:\/\/React\/\w+\/)?(webpack-internal:\/\/\/|webpack:\/\/(_N_E\/)?)/,
/^(rsc:\/\/React\/[^/]+\/)?(webpack-internal:\/\/\/|webpack:\/\/(_N_E\/)?)/,
''
)
.replace(/\?\d+$/, '')
Expand Down Expand Up @@ -277,7 +277,7 @@ export function getOverlayMiddleware(options: {

if (
!(
/^(rsc:\/\/React\/\w+\/)?(webpack-internal:\/\/\/|(file|webpack):\/\/)/.test(
/^(rsc:\/\/React\/[^/]+\/)?(webpack-internal:\/\/\/|(file|webpack):\/\/)/.test(
frame.file
) && frame.lineNumber
)
Expand Down

0 comments on commit 499327c

Please sign in to comment.