Merge pull request #87 from mozilla/use-string.endswith-86

Remove utils.endsWith
This commit is contained in:
Matthew Riley MacPherson 2015-10-14 19:00:27 +01:00
Родитель ee7495f5a3 f71f36635c
Коммит d7d390239b
4 изменённых файлов: 3 добавлений и 40 удалений

Просмотреть файл

@ -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'));
}
});
});