Skip to content

Commit

Permalink
feat: support for only room-code
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaa30 committed Apr 2, 2024
1 parent f6a2949 commit 7ac5871
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import live.hms.app2.R
import live.hms.app2.databinding.FragmentHomeBinding
import live.hms.app2.util.REGEX_MEETING_URL_CODE
import live.hms.app2.util.REGEX_PREVIEW_URL_CODE
import live.hms.app2.util.REGEX_ROOM_CODE
import live.hms.app2.util.REGEX_STREAMING_MEETING_URL_ROOM_CODE
import live.hms.app2.util.getInitEndpointEnvironment
import live.hms.app2.util.isValidMeetingUrl
Expand Down Expand Up @@ -139,6 +140,10 @@ class HomeFragment : Fragment() {
val groups = REGEX_PREVIEW_URL_CODE.findAll(url).toList()[0].groupValues
groups[2]
}
REGEX_ROOM_CODE.matches(url) -> {
val groups = REGEX_ROOM_CODE.findAll(url).toList()[0].groupValues
groups[0]
}
else -> null
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/live/hms/app2/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const val ENV_PROD = "prod-init"
const val ENV_QA = "qa-init"

val REGEX_MEETING_URL_CODE = Regex("https?://(.*.100ms.live)/meeting/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?")
val REGEX_ROOM_CODE = Regex("[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+")
val REGEX_PREVIEW_URL_CODE = Regex("https?://(.*.100ms.live)/preview/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?")
val REGEX_STREAMING_MEETING_URL_ROOM_CODE = Regex("https?://(.*.100ms.live)/streaming/meeting/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?")
val REGEX_MEETING_URL_ROOM_ID = Regex("https?://(.*.100ms.live)/meeting/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?")
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ package live.hms.app2.util

fun String.isValidMeetingUrl(): Boolean =
this.matches(REGEX_MEETING_URL_ROOM_ID) || this.matches(REGEX_MEETING_URL_CODE) || this.matches(REGEX_PREVIEW_URL_CODE) || this.matches(
REGEX_STREAMING_MEETING_URL_ROOM_CODE)
REGEX_STREAMING_MEETING_URL_ROOM_CODE) || this.matches(REGEX_ROOM_CODE)

fun String.getTokenEndpointEnvironment(): String = when {
this.contains("prod2.100ms.live") -> "prod-in"
this.contains(".app.100ms.live") -> "prod-in"
else -> "qa-in2"
this.contains(".qa-app.100ms.live") -> ENV_QA
else -> ENV_PROD
}

fun String.getInitEndpointEnvironment(): String = when {
this.contains("prod2.100ms.live") -> ENV_PROD
this.contains(".app.100ms.live") -> ENV_PROD
else -> ENV_QA
this.contains(".qa-app.100ms.live") -> ENV_QA
else -> ENV_PROD
}

fun String.toUniqueRoomSpecifier(): String {
Expand Down

0 comments on commit 7ac5871

Please sign in to comment.