mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Convert some usage of indexOf
to startsWith
/includes
where applicable
In many cases in the code you don't actually care about the index itself, but rather just want to know if something exists in a String/Array or if a String starts in a particular way. With modern JavaScript functionality, it's thus possible to remove a number of existing `indexOf` cases.
This commit is contained in:
parent
cdbc33ba06
commit
24a688d6c6
10 changed files with 22 additions and 28 deletions
|
@ -2533,13 +2533,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
var fontNameStr = fontName && fontName.name;
|
||||
var baseFontStr = baseFont && baseFont.name;
|
||||
if (fontNameStr !== baseFontStr) {
|
||||
info('The FontDescriptor\'s FontName is "' + fontNameStr +
|
||||
'" but should be the same as the Font\'s BaseFont "' +
|
||||
baseFontStr + '"');
|
||||
info(`The FontDescriptor\'s FontName is "${fontNameStr}" but ` +
|
||||
`should be the same as the Font\'s BaseFont "${baseFontStr}".`);
|
||||
// Workaround for cases where e.g. fontNameStr = 'Arial' and
|
||||
// baseFontStr = 'Arial,Bold' (needed when no font file is embedded).
|
||||
if (fontNameStr && baseFontStr &&
|
||||
baseFontStr.indexOf(fontNameStr) === 0) {
|
||||
baseFontStr.startsWith(fontNameStr)) {
|
||||
fontName = baseFont;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue