mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 16:30:13 +00:00
refactor
This commit is contained in:
parent
12678eb1c0
commit
ddc0b37d13
3 changed files with 13 additions and 13 deletions
|
@ -11,18 +11,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import { Users, UserProfiles } from '@/models/index';
|
import { Users, UserProfiles } from '@/models/index';
|
||||||
import { ILocalUser } from '@/models/entities/user';
|
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];
|
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareOrigin(ctx: Koa.Context) {
|
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
function normalizeUrl(url: string) {
|
function normalizeUrl(url?: string): string {
|
||||||
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const referer = ctx.headers['referer'];
|
const referer = ctx.headers['referer'];
|
||||||
|
|
||||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
|
|
|
@ -11,18 +11,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import { Users, UserProfiles } from '@/models/index';
|
import { Users, UserProfiles } from '@/models/index';
|
||||||
import { ILocalUser } from '@/models/entities/user';
|
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];
|
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareOrigin(ctx: Koa.Context) {
|
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
function normalizeUrl(url: string) {
|
function normalizeUrl(url?: string): string {
|
||||||
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const referer = ctx.headers['referer'];
|
const referer = ctx.headers['referer'];
|
||||||
|
|
||||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
|
|
|
@ -10,18 +10,18 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import { Users, UserProfiles } from '@/models/index';
|
import { Users, UserProfiles } from '@/models/index';
|
||||||
import { ILocalUser } from '@/models/entities/user';
|
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];
|
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareOrigin(ctx: Koa.Context) {
|
function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
function normalizeUrl(url: string) {
|
function normalizeUrl(url?: string): string {
|
||||||
return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
return url == null ? '' : url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
const referer = ctx.headers['referer'];
|
const referer = ctx.headers['referer'];
|
||||||
|
|
||||||
return (normalizeUrl(referer) == normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
|
|
Loading…
Reference in a new issue