Skip to content

Conversation

@maximedrn
Copy link
Contributor

@maximedrn maximedrn commented Jun 29, 2025

Hi! I came across an issue with your package after it applies some patches — it turns out that my project path included a single quote ('), which caused a runtime error.

This pull request addresses that edge case by escaping single quotes in the generated path string to ensure it's safely usable inside require('...') statements.

Before

/**
 * Get the dist dirname of this package.
 * @returns The dist dirname of this package
 */
export function getDistDirname() {
  const resolveOptions = { paths: [process.cwd()] };
  const nextWsPackagePath = //
    require.resolve('next-ws/package.json', resolveOptions);
  const nextWsDirName = resolveDirname(nextWsPackagePath);
  return `${nextWsDirName.replaceAll('\\', '/')}/dist`;
}

After

/**
 * Get the dist dirname of this package.
 * @returns The dist dirname of this package
 */
export function getDistDirname() {
  const resolveOptions = { paths: [process.cwd()] };
  const nextWsPackagePath = //
    require.resolve('next-ws/package.json', resolveOptions);
  const nextWsDirName = resolveDirname(nextWsPackagePath);
  return `${nextWsDirName}/dist`.replace(/\\/g, '/').replace(/'/g, "\\'");
}
-  return `${nextWsDirName.replaceAll('\\', '/')}/dist`;
+  return `${nextWsDirName}/dist`.replace(/\\/g, '/').replace(/'/g, "\\'");

@maximedrn maximedrn requested a review from k0d13 as a code owner June 29, 2025 11:53
@changeset-bot
Copy link

changeset-bot bot commented Jun 29, 2025

🦋 Changeset detected

Latest commit: 5275866

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…ndpoint and result in an incorrect monitored endpoint
@k0d13
Copy link
Owner

k0d13 commented Jun 29, 2025

Neat, needs formatting and changeset

@k0d13 k0d13 added server Modifications or updates to server-handling code patches Updates or fixes related to Next.js patches labels Jun 29, 2025
@maximedrn
Copy link
Contributor Author

Done, let me know if this is what you asked for :)

@k0d13 k0d13 merged commit b68bfdd into k0d13:main Jul 2, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patches Updates or fixes related to Next.js patches server Modifications or updates to server-handling code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants