-
Notifications
You must be signed in to change notification settings - Fork 7
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
1e7f19f
commit 27980ad
Showing
8 changed files
with
56 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
4 changes: 4 additions & 0 deletions
4
.../src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksManifestConfigurator.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
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,16 +1,31 @@ | ||
plugins { | ||
alias(libs.plugins.fgp.android) | ||
alias(libs.plugins.fgp.multiplatform) | ||
alias(libs.plugins.fgp.publish) | ||
alias(libs.plugins.kotlin.serialization) | ||
} | ||
|
||
freeletics { | ||
optIn("com.freeletics.khonshu.navigation.internal.InternalNavigationApi") | ||
|
||
multiplatform { | ||
addJvmTarget() | ||
addAndroidTarget() | ||
} | ||
} | ||
|
||
dependencies { | ||
} | ||
|
||
dependencies { | ||
api(projects.navigation) | ||
api(libs.coroutines.core) | ||
api(libs.turbine) | ||
implementation(libs.androidx.activity) | ||
implementation(libs.truth) | ||
"commonMainApi"(projects.navigation) | ||
"commonMainApi"(libs.kotlin.test) | ||
|
||
"commonMainImplementation"(libs.toml) | ||
"commonMainImplementation"(libs.serialization) | ||
|
||
"androidMainApi"(libs.coroutines.core) | ||
"androidMainApi"(libs.turbine) | ||
|
||
"androidMainImplementation"(libs.androidx.activity) | ||
"androidMainImplementation"(libs.truth) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...u/deeplinks/plugin/DeepLinkDefinitions.kt → ...vigation/deeplinks/DeepLinkDefinitions.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
29 changes: 29 additions & 0 deletions
29
...ting/src/commonMain/kotlin/com/freeletics/khonshu/navigation/deeplinks/DeepLinkTesting.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,29 @@ | ||
package com.freeletics.khonshu.navigation.deeplinks | ||
|
||
import kotlin.test.assertTrue | ||
|
||
public fun Set<DeepLinkHandler>.matchAllDeepLinks(defaultPrefixes: Set<DeepLinkHandler.Prefix>) { | ||
val codePrefixPatternCombinations = flatMapTo(HashSet()) { handler -> | ||
handler.prefixes.ifEmpty { defaultPrefixes }.flatMap { prefix -> | ||
handler.patterns.map { pattern -> | ||
prefix to pattern | ||
} | ||
} | ||
} | ||
|
||
val toml = DeepLinkDefinitions::class.java.getResourceAsStream("deeplinks.toml")!!.readAllBytes().decodeToString() | ||
val definitions = DeepLinkDefinitions.decodeFromString(toml) | ||
val definedPrefixPatternCombinations = definitions.deepLinks.values.flatMapTo(HashSet()) { deepLink -> | ||
deepLink.prefixes.ifEmpty { definitions.prefixes }.flatMap { prefix -> | ||
deepLink.patterns.map { pattern -> | ||
DeepLinkHandler.Prefix("${prefix.scheme}://${prefix.host}") to | ||
DeepLinkHandler.Pattern(pattern.value) | ||
} | ||
} | ||
} | ||
|
||
val codeOnly = codePrefixPatternCombinations - definedPrefixPatternCombinations | ||
assertTrue(codeOnly.isEmpty(), "The following deep links are not defined in TOML but are present in code: $codeOnly") | ||
val tomlOnly = definedPrefixPatternCombinations - codePrefixPatternCombinations | ||
assertTrue(tomlOnly.isEmpty(), "The following deep links are not defined in code but are present in the TOML file: $tomlOnly") | ||
} |