Merge pull request #87 from mozilla/use-string.endswith-86
Remove utils.endsWith
This commit is contained in:
Коммит
d7d390239b
10
src/utils.js
10
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче