Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Fix serverside transaction names on Windows #9526

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/nextjs/src/config/loaders/wrappingLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ export default function wrappingLoader(
}
} else if (wrappingTargetKind === 'page' || wrappingTargetKind === 'api-route') {
// Get the parameterized route name from this page's filepath
const parameterizedPagesRoute = path.posix
.normalize(
path
// Get the path of the file insde of the pages directory
.relative(pagesDir, this.resourcePath),
)
const parameterizedPagesRoute = path
// Get the path of the file insde of the pages directory
.relative(pagesDir, this.resourcePath)
// Replace all backslashes with forward slashes (windows)
.replace(/\\/g, '/')
// Add a slash at the beginning
.replace(/(.*)/, '/$1')
// Pull off the file extension
Expand Down Expand Up @@ -139,8 +138,11 @@ export default function wrappingLoader(
templateCode = templateCode.replace(/__ROUTE__/g, parameterizedPagesRoute.replace(/\\/g, '\\\\'));
} else if (wrappingTargetKind === 'server-component' || wrappingTargetKind === 'route-handler') {
// Get the parameterized route name from this page's filepath
const parameterizedPagesRoute = path.posix
.normalize(path.relative(appDir, this.resourcePath))
const parameterizedPagesRoute = path
// Get the path of the file insde of the app directory
.relative(appDir, this.resourcePath)
// Replace all backslashes with forward slashes (windows)
.replace(/\\/g, '/')
// Add a slash at the beginning
.replace(/(.*)/, '/$1')
// Pull off the file name
Expand Down