-
Notifications
You must be signed in to change notification settings - Fork 22
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 #136 from vinceglb/fix-path-linux-4
🐛 Fix URISyntaxException: Illegal character in path 4
- Loading branch information
Showing
2 changed files
with
37 additions
and
39 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
19 changes: 12 additions & 7 deletions
19
filekit-core/src/jvmTest/kotlin/io/github/vinceglb/filekit/core/platform/xdg/URITest.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 |
---|---|---|
@@ -1,34 +1,39 @@ | ||
package io.github.vinceglb.filekit.core.platform.xdg | ||
|
||
import java.io.File | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class URITest { | ||
@Test | ||
fun testSimpleURI() { | ||
val path = "image:///home/user/file.txt" | ||
val path = "file:///home/user/file.txt" | ||
val uri = path.toURI() | ||
assertEquals("/home/user/file.txt", uri.path) | ||
val file = File(uri) | ||
assertEquals("/home/user/file.txt", file.path) | ||
} | ||
|
||
@Test | ||
fun testURIWithSpaces() { | ||
val path = "file:///home/user/file with spaces.txt" | ||
val uri = path.toURI() | ||
assertEquals("/home/user/file with spaces.txt", uri.path) | ||
val file = File(uri) | ||
assertEquals("/home/user/file with spaces.txt", file.path) | ||
} | ||
|
||
@Test | ||
fun testURIWithSpecialCharacters() { | ||
val path = "file:///home/user/Ubuntu [24.04].file" | ||
val uri = path.toURI() | ||
assertEquals("/home/user/Ubuntu [24.04].file", uri.path) | ||
val file = File(uri) | ||
assertEquals("/home/user/Ubuntu [24.04].file", file.path) | ||
} | ||
|
||
@Test | ||
fun testURIWithoutScheme() { | ||
val path = "/home/user/file.txt" | ||
fun testToFixIssue129() { | ||
val path = "file:///home/dik/%D0%A0%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B9%20%D1%81%D1%82%D0%BE%D0%BB/Ubuntu%20[24.04].torrent" | ||
val uri = path.toURI() | ||
assertEquals("/home/user/file.txt", uri.path) | ||
val file = File(uri) | ||
assertEquals("/home/dik/Рабочий стол/Ubuntu [24.04].torrent", file.path) | ||
} | ||
} |