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:
Jonas Jenwald 2019-01-18 15:05:23 +01:00
parent cdbc33ba06
commit 24a688d6c6
10 changed files with 22 additions and 28 deletions

View file

@ -162,7 +162,7 @@ describe('ui_utils', function() {
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
var blobUrl = createObjectURL(typedArray, 'application/pdf');
// Sanity check to ensure that a "blob:" URL was returned.
expect(blobUrl.indexOf('blob:') === 0).toEqual(true);
expect(blobUrl.startsWith('blob:')).toEqual(true);
expect(getPDFFileNameFromURL(blobUrl + '?file.pdf')).toEqual('file.pdf');
});
@ -173,7 +173,7 @@ describe('ui_utils', function() {
var dataUrl = createObjectURL(typedArray, 'application/pdf',
/* forceDataSchema = */ true);
// Sanity check to ensure that a "data:" URL was returned.
expect(dataUrl.indexOf('data:') === 0).toEqual(true);
expect(dataUrl.startsWith('data:')).toEqual(true);
expect(getPDFFileNameFromURL(dataUrl + '?file1.pdf')).
toEqual('document.pdf');