Adopt the regex! macro - #166
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors reusable Rust regex singletons to use the new regex! macro (regex 1.13.0), reducing LazyLock/RegexBuilder boilerplate while keeping the existing validation and parsing behavior.
Changes:
- Replaced regex
LazyLocksingletons withregex!call sites for player-name validation, SQLite trace normalization, and SumoDB HTML parsing. - Exposed the player-name regex via a shared accessor and used
Regex::as_str()in the settings form’s HTMLpattern. - Replaced the SumoDB builder option (
dot_matches_new_line) with the inline(?s)flag.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| templates/settings.html | Uses the shared Rust player-name regex pattern string for HTML input validation. |
| src/handlers/admin.rs | Switches the SumoDB parsing regex from LazyLock/RegexBuilder to an inline regex! call with (?s). |
| src/data/player.rs | Replaces the player-name regex singleton with name_regex() backed by regex! and updates validation to use it. |
| src/data/mod.rs | Replaces debug SQLite trace whitespace-normalization singleton with an inline regex! call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
regex!Regex::as_str()for the HTML validation pattern(?s)flagLazyLockandRegexBuilderboilerplateThis PR is stacked on #164 because
regex!was introduced in regex 1.13.0.Two unrelated
LazyLockuses remain for the JST offset andSUMO_API_DRY_RUN;LazyLockis provided by the standard library rather than a Cargo dependency.Validation
cargo test --lockedcargo clippy --locked --all-targets -- -D warnings