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

chore: allow adding underscore (_), colon (:), comma (,), and dot(.) for the path part and underscore (_) for path parameters in addition to a-z A-Z - #2719

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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('validatePathName_hasTrailingSlash', () => {
test('validatePathName_invalidCharacters', () => {
// setup
const errorMessage =
'Each path part must use characters a-z A-Z 0-9 - and must not be empty.\nOptionally, a path part can be surrounded by { } to denote a path parameter.';
'Each path part must use characters a-z A-Z 0-9 - _ : , . and must not be empty.\nOptionally, a path part with characters a-z A-Z 0-9 - _ can be surrounded by { } to denote a path parameter.';

// test
expect(validatePathName('/invalid+/{char}')).toStrictEqual(errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const validatePathName = (name: string) => {

// Matches parameterized paths such as /book/{isbn}/page/{pageNum}
// This regex also catches the above conditions, but those are left in to provide clearer error messages.
if (!/^(?:\/(?:[a-zA-Z0-9\-]+|{[a-zA-Z0-9\-]+}))+$/.test(name)) {
return 'Each path part must use characters a-z A-Z 0-9 - and must not be empty.\nOptionally, a path part can be surrounded by { } to denote a path parameter.';
if (!/^(?:\/(?:[a-zA-Z0-9\-_:,.]+|{[a-zA-Z0-9\-_]+}))+$/.test(name)) {
return 'Each path part must use characters a-z A-Z 0-9 - _ : , . and must not be empty.\nOptionally, a path part with characters a-z A-Z 0-9 - _ can be surrounded by { } to denote a path parameter.';
}

return true;
Expand Down