diff --git a/src/utils.js b/src/utils.js index d5816047..2e267baa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,15 +1,5 @@ import semver from 'semver'; -/* - * Implementation of String.endsWith, which errors in node. - * - */ -export function endsWith(string, suffix) { - string = String(string); - suffix = String(suffix); - return string.indexOf(suffix, string.length - suffix.length) !== -1; -} - /* * Template tag for removing whitespace and new lines * in order to be able to use multiline template strings diff --git a/src/xpi.js b/src/xpi.js index dd577116..8e42a916 100644 --- a/src/xpi.js +++ b/src/xpi.js @@ -1,7 +1,6 @@ import yauzl from 'yauzl'; import { DuplicateZipEntryError } from 'exceptions'; -import { endsWith } from 'utils'; /* @@ -131,7 +130,7 @@ export default class Xpi { let files = []; for (let filename in metadata) { - if (endsWith(filename, ext)) { + if (filename.endsWith(ext)) { files.push(filename); } } diff --git a/tests/test.utils.js b/tests/test.utils.js index 134d606e..d0a16d65 100644 --- a/tests/test.utils.js +++ b/tests/test.utils.js @@ -1,31 +1,6 @@ import * as utils from 'utils'; -describe('utils.endsWith()', function() { - - it('returns true if a string ends with a specified string', () => { - assert.ok(utils.endsWith('Matthew', 'ew')); - }); - - it('returns false if a string does not end with a specified string', () => { - assert.notOk(utils.endsWith('Matthew', 'Mac')); - }); - - it('returns true if a string ends with itself', () => { - assert.ok(utils.endsWith('Matthew', 'Matthew')); - }); - - it('returns true if a strange character is present', () => { - assert.ok(utils.endsWith('G chord! 🎸', '🎸')); - }); - - it("casts to strings if strings aren't used", () => { - assert.ok(utils.endsWith(222, '22')); - assert.ok(utils.endsWith('Hello!!11', 11)); - }); -}); - - describe('utils.singleLineString()', function() { it('reduce a multiline template string into one string', () => { diff --git a/tests/test.xpi.js b/tests/test.xpi.js index 71abd709..41da6b8e 100644 --- a/tests/test.xpi.js +++ b/tests/test.xpi.js @@ -1,6 +1,5 @@ import { Readable } from 'stream'; -import { endsWith } from 'utils'; import Xpi from 'xpi'; import { DEFLATE_COMPRESSION, NO_COMPRESSION } from 'const'; import { DuplicateZipEntryError } from 'exceptions'; @@ -343,7 +342,7 @@ describe('Xpi.getFileAsStream()', function() { assert.equal(jsFiles[1], 'secondary.js'); for (let i = 0; i < jsFiles.length; i++) { - assert.ok(endsWith(jsFiles[i], '.js')); + assert.ok(jsFiles[i].endsWith('.js')); } }); }); @@ -364,7 +363,7 @@ describe('Xpi.getFileAsStream()', function() { assert.equal(cssFiles[1], 'styles.css'); for (let i = 0; i < cssFiles.length; i++) { - assert.ok(endsWith(cssFiles[i], '.css')); + assert.ok(cssFiles[i].endsWith('.css')); } }); });