Skip to content

Commit

Permalink
Code tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Jul 22, 2024
1 parent 728e115 commit 767b4ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function processSubroutines(expression, namedGroups) {
// `unclosedGroupCount`. If there are any backrefs in the expression, wrap with '()'
// instead of '(?:)' so that backrefs line up, in case there are backrefs inside the
// subroutine that refer to their parent capturing group
const subroutineValue = `${hasBackrefs ? '(' : '(?:'}${contents})`;
const subroutineValue = `(${hasBackrefs ? '' : '?:'}${contents})`;
openSubroutinesMap.set(subroutineName, {
contents,
unclosedGroupCount: countSubgroups(subroutineValue),
Expand Down Expand Up @@ -245,7 +245,7 @@ function countCapturesBeforeGroupName(expression, groupName) {
*/
function countSubgroups(expression) {
let num = 0;
forEachUnescaped(expression, String.raw`\(`, () => num++, Context.DEFAULT);
forEachUnescaped(expression, '\\(', () => num++, Context.DEFAULT);
return num;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function escapeV(str, context) {
// followed by the same unescaped symbol outside an interpolation, and since it won't be wrapped,
// the second symbol wouldn't be sandboxed from the one following it.
export function sandboxLoneDoublePunctuatorChar(str) {
return str.replace(new RegExp(String.raw`^([${doublePunctuatorChars}])(?!\1)`), (m, _, pos) => {
return str.replace(new RegExp(`^([${doublePunctuatorChars}])(?!\\1)`), (m, _, pos) => {
return `\\${m}${pos + 1 === str.length ? '' : m}`;
});
}
Expand Down

0 comments on commit 767b4ec

Please sign in to comment.