Skip to content

Commit

Permalink
fix: escape characters in compilationId (#3334)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Sep 1, 2024
1 parent 9a476f8 commit 30e465c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/src/server/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,13 @@ export const getAddressUrls = ({
};

// A unique name for WebSocket communication
const COMPILATION_ID_REGEX = /[^a-zA-Z0-9_-]/g;
export const getCompilationId = (
compiler: Rspack.Compiler | Rspack.Compilation,
) => `${compiler.name ?? ''}_${compiler.options.output.uniqueName ?? ''}`;
) => {
const uniqueName = compiler.options.output.uniqueName ?? '';
return `${compiler.name ?? ''}_${uniqueName.replace(COMPILATION_ID_REGEX, '_')}`;
};

export function getServerTerminator(
server: Server | Http2SecureServer,
Expand Down

0 comments on commit 30e465c

Please sign in to comment.