mirror of
https://github.com/MisskeyIO/misskey
synced 2024-11-24 07:06:22 +09:00
refactor
This commit is contained in:
parent
12678eb1c0
commit
ddc0b37d13
@ -11,18 +11,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Users, UserProfiles } from '@/models/index';
|
||||
import { ILocalUser } from '@/models/entities/user';
|
||||
|
||||
function getUserToken(ctx: Koa.Context) {
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
}
|
||||
|
||||
function compareOrigin(ctx: Koa.Context) {
|
||||
function normalizeUrl(url: string) {
|
||||
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||
function normalizeUrl(url?: string): string {
|
||||
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
||||
}
|
||||
|
||||
const referer = ctx.headers['referer'];
|
||||
|
||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||
}
|
||||
|
||||
// Init router
|
||||
|
@ -11,18 +11,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Users, UserProfiles } from '@/models/index';
|
||||
import { ILocalUser } from '@/models/entities/user';
|
||||
|
||||
function getUserToken(ctx: Koa.Context) {
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
}
|
||||
|
||||
function compareOrigin(ctx: Koa.Context) {
|
||||
function normalizeUrl(url: string) {
|
||||
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||
function normalizeUrl(url?: string): string {
|
||||
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
||||
}
|
||||
|
||||
const referer = ctx.headers['referer'];
|
||||
|
||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||
}
|
||||
|
||||
// Init router
|
||||
|
@ -10,18 +10,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Users, UserProfiles } from '@/models/index';
|
||||
import { ILocalUser } from '@/models/entities/user';
|
||||
|
||||
function getUserToken(ctx: Koa.Context) {
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
}
|
||||
|
||||
function compareOrigin(ctx: Koa.Context) {
|
||||
function normalizeUrl(url: string) {
|
||||
return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
||||
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||
function normalizeUrl(url?: string): string {
|
||||
return url == null ? '' : url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
||||
}
|
||||
|
||||
const referer = ctx.headers['referer'];
|
||||
|
||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||
}
|
||||
|
||||
// Init router
|
||||
|
Loading…
Reference in New Issue
Block a user