title editor: Fix name-duplication regex #3637
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous version was treating the parentheses as non-optional, and could come out with no match at all if the input name lacked them, leading to a traceback instead of the expected title editor window.
The new code will guarantee that
match.group(1)
always has some contents, even if — in the very degenerate case — the filename is something insane like(1).svg
.(In which case,
match.group(1) == '(1)'
and the rest of the match groups are empty. This would result in the output filename for the copy being generated as(1) (1).svg
. Which I would argue is actually more correct than / preferable to(2).svg
, in that admittedly pathological case.)