You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Chore: Update licenses.md (#13582)
This commit is contained in:
@@ -89,20 +89,35 @@ const getNotice = async (pkg: PackageInfo) => {
|
||||
return noticeLines.join('\n\n');
|
||||
};
|
||||
|
||||
const trimBeforeLicenseHeader = (text: string) => {
|
||||
const header = text.match(/#+ License[\n]/i);
|
||||
if (header) {
|
||||
return text.substring(header.index);
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
const readLicense = async (pkg: PackageInfo) => {
|
||||
let result = '';
|
||||
if (pkg.licenseText && !pkg.licenses.includes('UNKNOWN')) {
|
||||
result = pkg.licenseText;
|
||||
}
|
||||
|
||||
const resolvedLicenseToReadme = pkg.licenseFile && pkg.licenseFile.match(/\/README(\.\w+)?$/);
|
||||
|
||||
// By default, license-checker-rseidelsohn uses the README when the license can't be
|
||||
// found. This is often wrong, and we can do better:
|
||||
if (pkg.path && (!pkg.licenseFile || pkg.licenseFile.match(/\/README(\.\w+)?$/))) {
|
||||
if (pkg.path && (!pkg.licenseFile || resolvedLicenseToReadme)) {
|
||||
result = await readOrFetchRepositoryFile(pkg, ['LICENSE', 'LICENSE.md', 'LICENSE.txt', 'MIT-LICENSE.txt']);
|
||||
}
|
||||
|
||||
if (!result && pkg.licenseFile) {
|
||||
result = await readFile(pkg.licenseFile, 'utf8');
|
||||
|
||||
if (resolvedLicenseToReadme) {
|
||||
result = trimBeforeLicenseHeader(result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Some sources present licenses with different spacing.
|
||||
|
||||
// This function can be used to compare ignoring spaces.
|
||||
const wordsMatch = (text1: string, text2: string) => {
|
||||
const excludeRegex = /[ \t\n"]+/g;
|
||||
const excludeRegex = /[ \t\n"']+/g;
|
||||
text1 = text1.replace(excludeRegex, ' ').trim().toLowerCase();
|
||||
text2 = text2.replace(excludeRegex, ' ').trim().toLowerCase();
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ const matchMit = (licenseText: string) => {
|
||||
licenseText = licenseText.trim();
|
||||
|
||||
// Match headers similar to "MIT License" and "(The MIT License)"
|
||||
const headerRegex = /^.?(?:The )?(?:MIT License)?(?: .MIT.)?.?[\r\n \t]+/;
|
||||
const headerRegex = /^.?(?:This software is released under )?(?:The )?(?:MIT License)?(?: .MIT.)?.?[\r\n \t]+/i;
|
||||
licenseText = licenseText.replace(headerRegex, '');
|
||||
|
||||
const baseMitLicense = mit('[[copyright here]]').trim().replace(headerRegex, '');
|
||||
|
||||
const copyrightRegex = /^(Copyright .*)[\n]/i;
|
||||
const copyrightRegex = /^(Copyright .*[\n]){1,}[\n]?(All rights reserved.[\n])?/i;
|
||||
const baseLicenseWithoutCopyright = baseMitLicense.replace(copyrightRegex, '');
|
||||
const testLicenseTextWithoutCopyright = licenseText.replace(copyrightRegex, '');
|
||||
const copyrightMatch = copyrightRegex.exec(licenseText);
|
||||
|
||||
if (copyrightMatch && equalIgnoringSpacing(baseLicenseWithoutCopyright, testLicenseTextWithoutCopyright)) {
|
||||
return {
|
||||
copyright: copyrightMatch[1],
|
||||
copyright: copyrightMatch.slice(1).join('\n').trim(),
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
|
||||
119071
readme/licenses.md
119071
readme/licenses.md
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user