diff --git a/packages/backend/src/misc/acct.ts b/packages/backend/src/misc/acct.ts index 5b7767a106..cb6808b4b4 100644 --- a/packages/backend/src/misc/acct.ts +++ b/packages/backend/src/misc/acct.ts @@ -4,7 +4,7 @@ export type Acct = { }; export function parse(acct: string): Acct { - if (acct.startsWith("@")) acct = acct.substr(1); + if (acct.startsWith("@")) acct = acct.slice(1); const split = acct.split("@", 2); return { username: split[0], host: split[1] || null }; } diff --git a/packages/backend/src/server/api/service/discord.ts b/packages/backend/src/server/api/service/discord.ts index 9906d2f7ca..296e9cb481 100644 --- a/packages/backend/src/server/api/service/discord.ts +++ b/packages/backend/src/server/api/service/discord.ts @@ -18,7 +18,7 @@ function getUserToken(ctx: Koa.BaseContext): string | null { function compareOrigin(ctx: Koa.BaseContext): boolean { function normalizeUrl(url?: string): string { - return url ? (url.endsWith("/") ? url.substr(0, url.length - 1) : url) : ""; + return slice( url.length - 1) : url) : ""; } const referer = ctx.headers["referer"]; diff --git a/packages/backend/src/server/api/service/github.ts b/packages/backend/src/server/api/service/github.ts index f77c5f795d..da9d0931a0 100644 --- a/packages/backend/src/server/api/service/github.ts +++ b/packages/backend/src/server/api/service/github.ts @@ -18,7 +18,7 @@ function getUserToken(ctx: Koa.BaseContext): string | null { function compareOrigin(ctx: Koa.BaseContext): boolean { function normalizeUrl(url?: string): string { - return url ? (url.endsWith("/") ? url.substr(0, url.length - 1) : url) : ""; + return slice( url.length - 1) : url) : ""; } const referer = ctx.headers["referer"]; diff --git a/packages/calckey-js/src/acct.ts b/packages/calckey-js/src/acct.ts index 5b7767a106..cb6808b4b4 100644 --- a/packages/calckey-js/src/acct.ts +++ b/packages/calckey-js/src/acct.ts @@ -4,7 +4,7 @@ export type Acct = { }; export function parse(acct: string): Acct { - if (acct.startsWith("@")) acct = acct.substr(1); + if (acct.startsWith("@")) acct = acct.slice(1); const split = acct.split("@", 2); return { username: split[0], host: split[1] || null }; } diff --git a/packages/client/src/components/MkUserPreview.vue b/packages/client/src/components/MkUserPreview.vue index 6c3838fd2e..7aec661368 100644 --- a/packages/client/src/components/MkUserPreview.vue +++ b/packages/client/src/components/MkUserPreview.vue @@ -155,7 +155,7 @@ onMounted(() => { user.description.length > 400; } else { const query = props.q.startsWith("@") - ? Acct.parse(props.q.substr(1)) + ? Acct.parse(props.q.slice(1)) : { userId: props.q }; os.api("users/show", query).then((res) => { diff --git a/packages/client/src/scripts/gen-search-query.ts b/packages/client/src/scripts/gen-search-query.ts index 822572d3e3..fcf1f727ea 100644 --- a/packages/client/src/scripts/gen-search-query.ts +++ b/packages/client/src/scripts/gen-search-query.ts @@ -8,7 +8,7 @@ export async function genSearchQuery(v: any, q: string) { for (const at of q .split(" ") .filter((x) => x.startsWith("@")) - .map((x) => x.substr(1))) { + .map((x) => x.slice(1))) { if (at.includes(".")) { if (at === localHost || at === ".") { host = null; diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts index 34318ab0e9..ecea1ff2d4 100644 --- a/packages/client/src/scripts/search.ts +++ b/packages/client/src/scripts/search.ts @@ -19,7 +19,7 @@ export async function search() { } if (q.startsWith("#")) { - mainRouter.push(`/tags/${encodeURIComponent(q.substr(1))}`); + mainRouter.push(`/tags/${encodeURIComponent(q.slice(1))}`); return; } diff --git a/packages/client/src/scripts/theme-editor.ts b/packages/client/src/scripts/theme-editor.ts index 4828410177..fc015b6ac2 100644 --- a/packages/client/src/scripts/theme-editor.ts +++ b/packages/client/src/scripts/theme-editor.ts @@ -35,7 +35,7 @@ export const fromThemeString = (str?: string): ThemeValue => { } else if (str.startsWith('"')) { return { type: "css", - value: str.substr(1).trim(), + value: str.slice(1).trim(), }; } else { return str; diff --git a/packages/client/src/scripts/theme.ts b/packages/client/src/scripts/theme.ts index 383deb34ce..c52c2c217c 100644 --- a/packages/client/src/scripts/theme.ts +++ b/packages/client/src/scripts/theme.ts @@ -112,7 +112,7 @@ function compile(theme: Theme): Record { function getColor(val: string): tinycolor.Instance { // ref (prop) if (val[0] === "@") { - return getColor(theme.props[val.substr(1)]); + return getColor(theme.props[val.slice(1)]); } // ref (const) @@ -123,7 +123,7 @@ function compile(theme: Theme): Record { // func else if (val[0] === ":") { const parts = val.split("<"); - const func = parts.shift().substr(1); + const func = parts.shift().slice(1); const arg = parseFloat(parts.shift()); const color = getColor(parts.join("<"));