Skip to content

Commit

Permalink
Merge pull request #253 from cashapp/jw.canonicals.2023-09-26
Browse files Browse the repository at this point in the history
Do not map canonical URLs as fallbacks
  • Loading branch information
JakeWharton authored Sep 26, 2023
2 parents 4b8a9e7 + b69b211 commit 39716fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/kotlin/app/cash/licensee/licensesFallback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal val fallbackUrls = buildMap {
add("http://www.opensource.org/licenses/apache2.0.php")
add("https://www.opensource.org/licenses/apache2.0.php")
add("http://www.apache.org/licenses/LICENSE-2.0")
add("https://www.apache.org/licenses/LICENSE-2.0")
add("http://api.github.com/licenses/apache-2.0")
add("https://api.github.com/licenses/apache-2.0")
}
Expand All @@ -48,7 +47,6 @@ internal val fallbackUrls = buildMap {
add("http://www.opensource.org/licenses/mit-license.php")
add("https://www.opensource.org/licenses/mit-license.php")
add("http://opensource.org/licenses/MIT")
add("https://opensource.org/licenses/MIT")
add("http://api.github.com/licenses/mit")
add("https://api.github.com/licenses/mit")
}
Expand All @@ -62,13 +60,11 @@ internal val fallbackUrls = buildMap {
}
putLicense("BSD-3-Clause") {
add("http://opensource.org/licenses/BSD-3-Clause")
add("https://opensource.org/licenses/BSD-3-Clause")
add("http://api.github.com/licenses/bsd-3-clause")
add("https://api.github.com/licenses/bsd-3-clause")
}
putLicense("GPL-2.0-with-classpath-exception") {
add("http://www.gnu.org/software/classpath/license.html")
add("https://www.gnu.org/software/classpath/license.html")
}
putLicense("GPL-2.0", "GPL-2.0-or-later") {
add("http://choosealicense.com/licenses/gpl-2.0")
Expand Down Expand Up @@ -103,6 +99,9 @@ private fun MutableMap<String, List<SpdxLicense>>.putLicense(
?: throw AssertionError("No SPDX identifier '$it' in the embedded set")
}
for (url in buildList(urls)) {
if (SpdxLicenses.embedded.findByUrl(url).orEmpty().isNotEmpty()) {
throw AssertionError("$url is canonical and does not need to be a fallback")
}
if (put(url, licenses) != null) {
throw AssertionError("$url specified twice")
}
Expand Down

0 comments on commit 39716fb

Please sign in to comment.