OWASP / OWASP/Nest

Simplify regex in Pagination test by using character class instead of alternation

Open
#3,160 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
451
Forks
707
Avg merge
22h 59m
Merged PRs (30d)
91

Description

### Description

There is a small regex simplification opportunity in the pagination tests.

In `frontend/.../Pagination.test.tsx`, the following regular expression is used:

/Go to page (1|2)$/

Since this pattern only matches single characters, the alternation can be simplified using a character class for better readability and consistency.

### Suggested Change

Replace:

/Go to page (1|2)$/

With:

/Go to page [12]$/

### Reason

- Improves readability
- Avoids unnecessary alternation
- Aligns with common regex best practices used elsewhere in the codebase

### Scope

This change only affects test code and does not alter application behavior.

### Reference

[SonarCloud](https://sonarcloud.io/project/issues?impactSeverities=MEDIUM&issueStatuses=OPEN%2CCONFIRMED&id=OWASP_Nest&open=AZhjQVNGifmo5YfJJ5vW)

Contributor guide

Open the contributing guide

Research direction

Open frontend/.../Pagination.test.tsx and locate the pagination test using /Go to page (1|2)$/. Replace that pattern with /Go to page [12]$/ and verify the Pagination tests still pass with the same matching behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, testing
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.