1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/tools/licenses/utils/matchApache2.ts
Henry Heino 02bdb7a79c
Docs: Include dependency overview (#10911)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-08-22 21:53:27 +01:00

27 lines
651 B
TypeScript

import apache2 from '../licenseText/apache2';
import wordsMatch from './equalIgnoringSpacing';
const matchApache2 = (text: string) => {
const termsEndString = 'END OF TERMS AND CONDITIONS';
const termsEndStringIndex = text.indexOf(termsEndString);
if (termsEndStringIndex === -1) {
return null;
}
const termsEndIndex = termsEndStringIndex + termsEndString.length;
const textWithoutAppendices = text.substring(0, termsEndIndex);
if (!wordsMatch(apache2, textWithoutAppendices)) {
return null;
}
const textAppendix = text.substring(termsEndIndex, text.length);
return {
appendix: textAppendix,
};
};
export default matchApache2;