[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify regex on UI and Utils to Allow Underscores #720

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/ui/modals/add-edit-link-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,10 @@ function AddEditLinkModal({
name="key"
id={`key-${randomIdx}`}
required
pattern="[\p{L}\p{N}\p{Pd}\/]+"
pattern="^(?!_)[\p{L}\p{N}\p{Pd}_\/]+"
=> {
e.currentTarget.setCustomValidity(
"Only letters, numbers, '-', and '/' are allowed.",
"Only letters, numbers, '-', and '/' are allowed. Underscores '_', if present, should not be placed at the beginning. ",
);
}}
disabled={props && lockKey}
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/functions/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const validDomainRegex = new RegExp(
/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,
);

export const validKeyRegex = new RegExp(/^[0-9A-Za-z\u0080-\uFFFF\/\-]*$/u);
export const validKeyRegex = new RegExp(/^(?!_)[0-9A-Za-z\u0080-\uFFFF_\/\-]*$/u);

export const validSlugRegex = new RegExp(/^[a-zA-Z0-9\-]+$/);

Expand Down