-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e29bd2
commit f29c444
Showing
6 changed files
with
36 additions
and
4 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
23 changes: 23 additions & 0 deletions
23
app/shared/src/jsMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundContainer.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,23 @@ | ||
package dev.schlaubi.tonbrett.app.components | ||
|
||
import io.ktor.http.URLBuilder | ||
import kotlinx.browser.window | ||
|
||
val appId = window.location.host.substringBefore(".") | ||
|
||
actual fun String.proxyUrl(): String { | ||
return if (window.location.host.endsWith("discordsays.com")) { | ||
URLBuilder(this).apply { | ||
val specifier = when (host) { | ||
"cdn.discordapp.com" -> "cdn" | ||
"cdn.jsdelivr.net" -> "jsdelivr" | ||
else -> error("Unknown host: $host") | ||
} | ||
|
||
host = "${appId}.discordsays.com" | ||
pathSegments = listOf(".proxy", specifier) + pathSegments.filter(String::isNotBlank) | ||
}.buildString() | ||
} else { | ||
this | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
app/shared/src/nonWebMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundContainer.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,6 @@ | ||
@file:JvmName("SoundContainerNonWeb") | ||
package dev.schlaubi.tonbrett.app.components | ||
|
||
import kotlin.jvm.JvmName | ||
|
||
actual fun String.proxyUrl() = this |
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
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
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