-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SelectorHelpers.computeAbsoluteUrl
part of #1117
- Loading branch information
Showing
2 changed files
with
90 additions
and
10 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
85 changes: 85 additions & 0 deletions
85
...hared/app-data/src/commonTest/kotlin/domain/mediasource/web/format/SelectorHelpersTest.kt
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2024 OpenAni and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. | ||
* | ||
* https://github.com/open-ani/ani/blob/main/LICENSE | ||
*/ | ||
|
||
package me.him188.ani.app.domain.mediasource.web.format | ||
|
||
import me.him188.ani.test.TestContainer | ||
import me.him188.ani.test.TestFactory | ||
import me.him188.ani.test.runDynamicTests | ||
import kotlin.test.assertEquals | ||
|
||
/** | ||
* @see SelectorHelpers.computeAbsoluteUrl | ||
*/ | ||
@TestContainer | ||
class ComputeAbsoluteUrlTest { | ||
@TestFactory | ||
fun computeAbsoluteUrlTest() = runDynamicTests { | ||
fun case( | ||
expected: String, | ||
baseUrl: String, | ||
relativeUrl: String, | ||
) = add("$baseUrl + $relativeUrl = $expected") { | ||
assertEquals( | ||
expected, | ||
SelectorHelpers.computeAbsoluteUrl(baseUrl, relativeUrl), | ||
) | ||
} | ||
|
||
case( | ||
"https://example.com/relative", | ||
"https://example.com", "relative", | ||
) | ||
|
||
case( | ||
"https://example.com/relative", | ||
"https://example.com", "/relative", | ||
) | ||
|
||
case( | ||
"https://example.com/relative", | ||
"https://example.com/", "/relative", | ||
) | ||
|
||
case( | ||
"https://example.com/relative/", | ||
"https://example.com/", "/relative/", | ||
) | ||
|
||
case( | ||
"https://example.com/relative/foo", | ||
"https://example.com/", "/relative/foo", | ||
) | ||
|
||
case( | ||
"https://example.com/relative/foo/../bar", | ||
"https://example.com/", "/relative/foo/../bar", | ||
) | ||
|
||
case( | ||
"https://example.com/", | ||
"https://example.com/", "", | ||
) | ||
|
||
case( | ||
"http://localhost/", | ||
"", "", | ||
) | ||
|
||
case( | ||
"http://localhost/test", | ||
"", "/test", | ||
) | ||
|
||
case( | ||
"http://localhost/test", | ||
"", "test", | ||
) | ||
} | ||
} |