-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from skyway/feat/update-validation-of-room-name
expand room name limits
- Loading branch information
Showing
3 changed files
with
46 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
export const errorMessageForInvalidRoomType = `Invalid room type! it should be 'SFU' or 'P2P'.`; | ||
export const isValidRoomType = (type: string): boolean => { | ||
if (type === "SFU" || type === "P2P") { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
export const maxRoomIdLength = 16; | ||
export const roomIdRe = "^[0-9a-z_-]{4,16}$"; | ||
export const isValidRoomId = (name: string): boolean => { | ||
return new RegExp(roomIdRe).test(name); | ||
// Channel、Memberのnameとして使用可能な文字種 | ||
// from https://skyway.ntt.com/en/docs/user-guide/commons/quotas-and-limits/ | ||
// > Allowed characters: Only characters composed of a-z, A-Z, 0-9, -, ., _, %, * | ||
// - * is allowed but not used | ||
// > Number of characters: 1~128 characters (0 characters are not allowed) | ||
// - 4 characters or more to reduce the possibility of unexpected users using the same Room Id | ||
// - 120 characters or less to be added prefix 'P2P_' or 'SFU_' | ||
const minRoomNameLength = 4; | ||
export const maxRoomNameLength = 120; | ||
export const messageForValidRoomName = `${minRoomNameLength}~${maxRoomNameLength} characters of half-width alphanumeric, '-', '.', '_', '%'.`; | ||
export const errorMessageForInvalidRoomName = `Invalid room name! it should be ${messageForValidRoomName}`; | ||
export const roomNameRegex = `^[a-zA-Z0-9-._%]{${minRoomNameLength},${maxRoomNameLength}}$`; | ||
export const isValidRoomName = (name: string): boolean => { | ||
return new RegExp(roomNameRegex).test(name); | ||
}; |