fix(process): normalize ports that end a sentence
Contextual port normalization refused any port followed by a period, so common log lines such as "Listening on port: 8080." or "http://localhost:8080." kept their run-specific port and equivalent captures compared as changed. Accept a sentence-ending period while still refusing a period that continues a decimal, version, or host name, and bump the committed port-normalization version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
33bf585185
commit
db98a51dd1
@@ -41,9 +41,11 @@ export const normalizeProcessText = (
|
||||
return normalized;
|
||||
};
|
||||
|
||||
// A port may end a sentence, but a period followed by a word character
|
||||
// continues a decimal, version, or host name and is not a port boundary.
|
||||
const normalizePortTokens = (value: string): string => {
|
||||
const endpointNormalized = value.replaceAll(
|
||||
/(\b[a-z][a-z0-9+.-]*:\/\/[^\s/?#"'<>]+|\blocalhost|\b(?:\d{1,3}\.){3}\d{1,3}|\[[\da-f:.%]+\]):(\d{1,5})(?![\w.@:])/giu,
|
||||
/(\b[a-z][a-z0-9+.-]*:\/\/[^\s/?#"'<>]+|\blocalhost|\b(?:\d{1,3}\.){3}\d{1,3}|\[[\da-f:.%]+\]):(\d{1,5})(?![\w@:]|\.\w)/giu,
|
||||
(match: string, endpoint: string, port: string) => {
|
||||
if (Number(port) > 65_535) return match;
|
||||
const isEndpoint = endpoint.includes("://")
|
||||
@@ -54,7 +56,7 @@ const normalizePortTokens = (value: string): string => {
|
||||
},
|
||||
);
|
||||
return endpointNormalized.replaceAll(
|
||||
/(\b(?:port|tcp_port|udp_port|listen)\b["']?\s*[:=]\s*)(\d{1,5})(?![\w.])/giu,
|
||||
/(\b(?:port|tcp_port|udp_port|listen)\b["']?\s*[:=]\s*)(\d{1,5})(?!\w|\.\w)/giu,
|
||||
(match: string, prefix: string, port: string) =>
|
||||
Number(port) <= 65_535 ? `${prefix}<port>` : match,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user