Skip to content

Commit 21e4301

Browse files
authored
Merge pull request #5642 from Tyriar/startsWith
Prefer startsWith over indexOf === 0
2 parents 9eaf5b4 + 39037ee commit 21e4301

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/common/InputHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ export class InputHandler extends Disposable implements IInputHandler {
17821782
* @param term The terminal name to evaluate
17831783
*/
17841784
private _is(term: string): boolean {
1785-
return (this._optionsService.rawOptions.termName + '').indexOf(term) === 0;
1785+
return (this._optionsService.rawOptions.termName + '').startsWith(term);
17861786
}
17871787

17881788
/**

src/common/input/XParseColor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function parseColor(data: string): [number, number, number] | undefined {
2424
if (!data) return;
2525
// also handle uppercases
2626
let low = data.toLowerCase();
27-
if (low.indexOf('rgb:') === 0) {
27+
if (low.startsWith('rgb:')) {
2828
// 'rgb:' specifier
2929
low = low.slice(4);
3030
const m = RGB_REX.exec(low);
@@ -36,7 +36,7 @@ export function parseColor(data: string): [number, number, number] | undefined {
3636
Math.round(parseInt(m[3] || m[6] || m[9] || m[12], 16) / base * 255)
3737
];
3838
}
39-
} else if (low.indexOf('#') === 0) {
39+
} else if (low.startsWith('#')) {
4040
// '#' specifier
4141
low = low.slice(1);
4242
if (HASH_REX.exec(low) && [3, 6, 9, 12].includes(low.length)) {

0 commit comments

Comments
 (0)