Various improvements #169

Merged
schmelczer merged 78 commits from asch/saturday into main 2025-11-30 15:24:52 +00:00
Showing only changes of commit 29784eb600 - Show all commits

Use named group

Andras Schmelczer 2025-11-28 21:23:55 +00:00

View file

@ -9,7 +9,7 @@ import { isBinary } from "../utils/is-binary";
import type { ServerConfig } from "../services/server-config";
export class FileOperations {
private static readonly PARENTHESES_REGEX = / \((\d+)\)$/;
private static readonly PARENTHESES_REGEX = / \((?<count>\d+)\)$/;
private readonly fs: SafeFileSystemOperations;
copilot-pull-request-reviewer[bot] commented 2025-11-30 15:03:03 +00:00 (Migrated from github.com)

[nitpick] The named capture group is called 'count' but is accessed as 'groups?.count' in the code at line 265. For consistency with the previous code that used groups?.[0], consider either keeping the array access pattern or updating the comment to explain the named group convention.

[nitpick] The named capture group is called 'count' but is accessed as 'groups?.count' in the code at line 265. For consistency with the previous code that used groups?.[0], consider either keeping the array access pattern or updating the comment to explain the named group convention.
public constructor(
@ -251,7 +251,8 @@ export class FileOperations {
: "";
let stem = extension ? nameParts.slice(0, -1).join(".") : fileName;
let currentCount = Number.parseInt(
FileOperations.PARENTHESES_REGEX.exec(stem)?.[1] ?? "0"
FileOperations.PARENTHESES_REGEX.exec(stem)?.groups?.["count"] ??
"0"
);
stem = stem.replace(FileOperations.PARENTHESES_REGEX, "");