| |
@@ -644,15 +644,23 @@
|
| |
|
| |
|
| |
function validateLicense(matches) {
|
| |
- if (!(Array.isArray(matches) && matches.length === 4)){
|
| |
+ if (!(Array.isArray(matches) && matches.length >= 4)){
|
| |
return [false, "Malformed or unrecognized license tag."];
|
| |
}
|
| |
let [all, tag, link, id] = matches;
|
| |
- let license = licenses[id];
|
| |
+ let license = null;
|
| |
+ if (licenses[id])
|
| |
+ license = licenses[id];
|
| |
+ for (var key in licenses){
|
| |
+ if (licenses[key]["Magnet link"]==link)
|
| |
+ license=licenses[key];
|
| |
+ if (licenses[key]["URL"]==link)
|
| |
+ license=licenses[key];
|
| |
+ }
|
| |
if(!license){
|
| |
return [false, `Unrecognized license "${id}"`];
|
| |
}
|
| |
- if(license["Magnet link"] != link){
|
| |
+ if (!(license["Magnet link"] == link || license["URL"] == link)){
|
| |
return [false, `License magnet link does not match for "${id}".`];
|
| |
}
|
| |
return [true, `Recognized license: "${id}".`];
|
| |
I still found some issues with the emailselfdefense.org example, in which the license is stated as
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
My suggested changes are:
* Allow for length >= 4 since somebody may write "GPL2.0 or later" or something like that. It should still work if the tag follows the new recommendations.
* Match the link to the URL or Magnet Link fields in the licenses table. Currently it matches only by id, and the link field is only used to fail the match if the link is not the same as in the table.
My reasoning comes from the documentation stating that the id is not used for matching, only the magnet link is. My changes should accommodate for people who use a custom link, as long as the license identifier matches the one in our license table, or for people who use a custom identifier, as long as the link is in our table.
I'd like an opinion on both the logic and my code, since it is very likely that I may be doing something stupid.