Skip to content

Commit

Permalink
Fix some copy paste errors in Url and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed Jan 16, 2024
1 parent b14fab0 commit 3eddc8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions uri/src/commonMain/kotlin/com/eygraber/uri/Url.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Url internal constructor(
* @return the encoded scheme-specific-part
*/
override val encodedSchemeSpecificPart: String by lazy {
requireNotNull(uri.scheme) {
requireNotNull(uri.encodedSchemeSpecificPart) {
"Url requires a non-null schemeSpecificPart"
}
}
Expand All @@ -57,7 +57,7 @@ public class Url internal constructor(
* @return the authority for this URI
*/
override val authority: String by lazy {
requireNotNull(uri.scheme) {
requireNotNull(uri.authority) {
"Url requires a non-null authority"
}
}
Expand All @@ -72,7 +72,7 @@ public class Url internal constructor(
* @return the authority for this URL
*/
override val encodedAuthority: String by lazy {
requireNotNull(uri.scheme) {
requireNotNull(uri.encodedAuthority) {
"Url requires a non-null authority"
}
}
Expand Down
12 changes: 12 additions & 0 deletions uri/src/commonTest/kotlin/com/eygraber/uri/UrlTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ class UrlTests {
"Url host must not be null"
)
}

@Test
fun test_urlProperties() {
val url = Url.parse("https://[email protected]/?q=bar baz#")
assertEquals("https", url.scheme)
assertEquals("//[email protected]/?q=bar baz", url.schemeSpecificPart)
assertEquals("[email protected]", url.authority)
assertEquals("foo", url.userInfo)
assertEquals("google.com", url.host)
assertEquals("/", url.path)
assertEquals("q=bar baz", url.query)
}
}

0 comments on commit 3eddc8b

Please sign in to comment.