nits
This commit is contained in:
@@ -9,6 +9,7 @@ export type ServiceConfig = {
|
||||
port: number
|
||||
version?: string
|
||||
hostnames: string[]
|
||||
hostnamesSet: Set<string>
|
||||
appHostname: string
|
||||
safelinkEnabled: boolean
|
||||
safelinkPdsUrl?: string
|
||||
@@ -72,6 +73,7 @@ export const envToCfg = (env: Environment): Config => {
|
||||
port: env.port ?? 3000,
|
||||
version: env.version,
|
||||
hostnames: env.hostnames,
|
||||
hostnamesSet: new Set(env.hostnames),
|
||||
appHostname: env.appHostname ?? 'bsky.app',
|
||||
safelinkEnabled: env.safelinkEnabled ?? false,
|
||||
safelinkPdsUrl: env.safelinkPdsUrl,
|
||||
|
||||
@@ -84,13 +84,15 @@ const getUrl = (ctx: AppContext, req: Request, id: string) => {
|
||||
return `${baseUrl}/${id}`
|
||||
}
|
||||
const host = req.headers.host ?? ''
|
||||
const baseUrl = ctx.cfg.service.hostnames.includes(host)
|
||||
const baseUrl = ctx.cfg.service.hostnamesSet.has(host)
|
||||
? `https://${host}`
|
||||
: `https://${ctx.cfg.service.hostnames[0]}`
|
||||
return `${baseUrl}/${id}`
|
||||
}
|
||||
|
||||
const normalizedPathFromParts = (parts: string[]): string => {
|
||||
// When given ['path1', 'path2', 'te:fg'], output should be
|
||||
// /path1/path2/te:fg
|
||||
return (
|
||||
'/' +
|
||||
parts
|
||||
|
||||
Reference in New Issue
Block a user