refactor: ♻️ substr -> slice
This commit is contained in:
parent
1c7a805ff1
commit
64322721b6
9 changed files with 10 additions and 10 deletions
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -112,7 +112,7 @@ function compile(theme: Theme): Record<string, string> {
|
|||
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<string, string> {
|
|||
// 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("<"));
|
||||
|
||||
|
|
Loading…
Reference in a new issue