mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
27 lines
651 B
TypeScript
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;
|