eslint: Fix @typescript-eslint/prefer-string-starts-ends-with.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-12-21 17:03:12 -08:00 committed by Tim Abbott
parent c943dc5035
commit c16837a664
3 changed files with 5 additions and 5 deletions

View File

@ -107,7 +107,7 @@ export function return_to_web_public_hash(): void {
export function get_full_url(hash: string): string { export function get_full_url(hash: string): string {
const location = window.location; const location = window.location;
if (hash.charAt(0) !== "#" && hash !== "") { if (!hash.startsWith("#") && hash !== "") {
hash = "#" + hash; hash = "#" + hash;
} }
@ -115,7 +115,7 @@ export function get_full_url(hash: string): string {
let pathname = location.pathname; let pathname = location.pathname;
if (pathname === undefined) { if (pathname === undefined) {
pathname = "/"; pathname = "/";
} else if (pathname === "" || pathname.charAt(0) !== "/") { } else if (pathname === "" || !pathname.startsWith("/")) {
pathname = "/" + pathname; pathname = "/" + pathname;
} }

View File

@ -210,7 +210,7 @@ export function patch(
} }
export function xhr_error_message(message: string, xhr: JQuery.jqXHR<unknown>): string { export function xhr_error_message(message: string, xhr: JQuery.jqXHR<unknown>): string {
if (xhr.status.toString().charAt(0) === "4" && xhr.responseJSON?.msg) { if (xhr.status >= 400 && xhr.status < 500 && xhr.responseJSON?.msg) {
// Only display the error response for 4XX, where we've crafted // Only display the error response for 4XX, where we've crafted
// a nice response. // a nice response.
const server_response_html = _.escape(xhr.responseJSON.msg); const server_response_html = _.escape(xhr.responseJSON.msg);

View File

@ -11,7 +11,7 @@ type Operator = {operator: string; operand: string; negated?: boolean};
export function build_reload_url(): string { export function build_reload_url(): string {
let hash = window.location.hash; let hash = window.location.hash;
if (hash.length !== 0 && hash[0] === "#") { if (hash.length !== 0 && hash.startsWith("#")) {
hash = hash.slice(1); hash = hash.slice(1);
} }
return "+oldhash=" + encodeURIComponent(hash); return "+oldhash=" + encodeURIComponent(hash);
@ -177,7 +177,7 @@ export function parse_narrow(hash: string): Operator[] | undefined {
} }
let negated = false; let negated = false;
if (operator[0] === "-") { if (operator.startsWith("-")) {
negated = true; negated = true;
operator = operator.slice(1); operator = operator.slice(1);
} }