Skip to content

Commit 963c5e6

Browse files
authored
Merge pull request #1037 from mikepenz/feature/1034
Introduce fallback mirror for license content loading
2 parents 918c624 + bb3261d commit 963c5e6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/mapping/SpdxLicense.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,15 @@ enum class SpdxLicense(
396396
}),
397397
BSD_2_Clause("BSD 2-Clause \"Simplified\" License", "BSD-2-Clause", customMatcher = { name, url ->
398398
name.equals("BSD 2-Clause License", true)
399-
|| url?.endsWith("opensource.org/licenses/BSD-2-Clause", true) == true
400-
|| url?.endsWith("opensource.org/licenses/bsd-license", true) == true
399+
|| url?.endsWith("opensource.org/licenses/BSD-2-Clause", true) == true
400+
|| url?.endsWith("opensource.org/licenses/bsd-license", true) == true
401401
}),
402402
BSD_3_Clause("BSD 3-Clause \"New\" or \"Revised\" License", "BSD-3-Clause", customMatcher = { name, url ->
403403
name.equals("New BSD License", true) || name.equals("Modified BSD License", true) || name.equals(
404404
"BSD 3-clause",
405405
true
406406
) ||
407-
url?.endsWith("opensource.org/licenses/BSD-3-Clause", true) == true
407+
url?.endsWith("opensource.org/licenses/BSD-3-Clause", true) == true
408408
}),
409409
MIT("MIT License", "MIT", customMatcher = { name, _ ->
410410
name.contains("MIT", true)
@@ -433,6 +433,8 @@ enum class SpdxLicense(
433433

434434
fun getTxtUrl(): String = customTxtUrl ?: "https://spdx.org/licenses/$id.txt"
435435

436+
fun getFallbackTxtUrl(): String = "https://raw.githubusercontent.com/spdx/license-list-data/refs/heads/main/text/$id.txt"
437+
436438
companion object {
437439
internal fun find(key: String): SpdxLicense? {
438440
for (l: SpdxLicense in SpdxLicense.values()) {

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/LicenseUtil.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ object LicenseUtil {
3333
try {
3434
val enumLicense = SpdxLicense.find(spdxId)
3535
if (enumLicense != null) {
36-
val licUrl = enumLicense.getTxtUrl()
37-
val singleLicense: String? = loadLicenseCached(licUrl)
36+
val singleLicense: String? = loadLicenseCached(enumLicense.getTxtUrl()) ?: loadLicenseCached(enumLicense.getFallbackTxtUrl())
3837
if (singleLicense?.isNotBlank() == true) {
3938
name = enumLicense.fullName
4039
url = enumLicense.getUrl()

0 commit comments

Comments
 (0)