File tree Expand file tree Collapse file tree
main/java/com/pedro/common
test/java/com/pedro/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ class UrlParser private constructor(
7171 val path = getFullPath().ifEmpty { query ? : " " }.replace(queries, " " )
7272 val segments = path.split(' /' ).filter { it.isNotEmpty() }
7373 return when (segments.size) {
74+ 0 -> " "
7475 1 , 2 -> segments[0 ]
7576 else -> segments.subList(0 , 2 ).joinToString(" /" )
7677 }
Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ import java.net.URISyntaxException
99 */
1010class UrlParserTest {
1111
12+ @Test
13+ fun testNoAppName () {
14+ val url = " rtmp://localhost:1935/"
15+ val urlParser = UrlParser .parse(url, arrayOf(" rtmp" ))
16+ assertEquals(" rtmp" , urlParser.scheme)
17+ assertEquals(" localhost" , urlParser.host)
18+ assertEquals(1935 , urlParser.port)
19+ assertEquals(" " , urlParser.getAppName())
20+ }
21+
1222 @Test
1323 fun testRtmpUrls () {
1424 try {
You can’t perform that action at this time.
0 commit comments