提交 02996aac 编写于 作者: C Christof Marti

Remove strings.endsWith() (#103454)

上级 7bbd1338
......@@ -144,20 +144,6 @@ export function stripWildcards(pattern: string): string {
return pattern.replace(/\*/g, '');
}
/**
* @deprecated ES6: use `String.endsWith`
*/
export function endsWith(haystack: string, needle: string): boolean {
const diff = haystack.length - needle.length;
if (diff > 0) {
return haystack.indexOf(needle, diff) === diff;
} else if (diff === 0) {
return haystack === needle;
} else {
return false;
}
}
export interface RegExpOptions {
matchCase?: boolean;
wholeWord?: boolean;
......
......@@ -140,18 +140,6 @@ suite('Strings', () => {
assert.strictEqual(strings.escape('<foo>Hello</foo>'), '&lt;foo&gt;Hello&lt;/foo&gt;');
});
test('endsWith', () => {
assert(strings.endsWith('foo', 'o'));
assert(strings.endsWith('foo', 'oo'));
assert(strings.endsWith('foo', 'foo'));
assert(strings.endsWith('foo bar foo', 'foo'));
assert(!strings.endsWith('foo', 'f'));
assert(!strings.endsWith('', 'f'));
assert(strings.endsWith('foo', ''));
assert(strings.endsWith('', ''));
assert(strings.endsWith('/', '/'));
});
test('ltrim', () => {
assert.strictEqual(strings.ltrim('foo', 'f'), 'oo');
assert.strictEqual(strings.ltrim('foo', 'o'), 'foo');
......
......@@ -3,24 +3,24 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { endsWith, rtrim } from 'vs/base/common/strings';
import { rtrim } from 'vs/base/common/strings';
export function normalizeGitHubUrl(url: string): string {
// If the url has a .git suffix, remove it
if (endsWith(url, '.git')) {
if (url.endsWith('.git')) {
url = url.substr(0, url.length - 4);
}
// Remove trailing slash
url = rtrim(url, '/');
if (endsWith(url, '/new')) {
if (url.endsWith('/new')) {
url = rtrim(url, '/new');
}
if (endsWith(url, '/issues')) {
if (url.endsWith('/issues')) {
url = rtrim(url, '/issues');
}
return url;
}
\ No newline at end of file
}
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as strings from 'vs/base/common/strings';
import { EditorInput, EditorModel, ITextEditorModel } from 'vs/workbench/common/editor';
import { URI } from 'vs/base/common/uri';
import { IReference } from 'vs/base/common/lifecycle';
......@@ -97,7 +96,7 @@ export class WalkThroughInput extends EditorInput {
if (!this.promise) {
this.promise = this.textModelResolverService.createModelReference(this.options.resource)
.then(ref => {
if (strings.endsWith(this.resource.path, '.html')) {
if (this.resource.path.endsWith('.html')) {
return new WalkThroughModel(ref, []);
}
......
......@@ -280,7 +280,7 @@ export class WalkThroughPart extends EditorPane {
}
const content = model.main.textEditorModel.getValue(EndOfLinePreference.LF);
if (!strings.endsWith(input.resource.path, '.md')) {
if (!input.resource.path.endsWith('.md')) {
this.content.innerHTML = content;
this.updateSizeClasses();
this.decorateContent();
......
......@@ -11,7 +11,6 @@ import * as os from 'os';
import * as fs from 'fs';
import * as cp from 'child_process';
import { endsWith } from 'vs/base/common/strings';
import { IExtHostWorkspaceProvider } from 'vs/workbench/api/common/extHostWorkspace';
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
import { ProxyAgent } from 'vscode-proxy-agent';
......@@ -289,7 +288,7 @@ function noProxyFromEnv(envValue?: string) {
return () => false;
}
return (hostname: string, port: string) => filters.some(({ domain, port: filterPort }) => {
return endsWith(`.${hostname.toLowerCase()}`, domain) && (!filterPort || port === filterPort);
return `.${hostname.toLowerCase()}`.endsWith(domain) && (!filterPort || port === filterPort);
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册