/
githubmirror
/
gogs
Обзор
Документация
Войти
/
githubmirror
/
gogs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
web/src/lib/url.ts
12 строк
631 B
ᴊᴏᴇ ᴄʜᴇɴ
Embed WebContext and add /api/web/user-info endpoint (#8282)
21 май 2026, 21:43
Не верифицирован
21 май 2026, 21:43
90790b2
Код
Авторство
О чём код?
import { webContext } from "./context"; // subUrl prefixes an internal absolute path with the deployment subpath so // links work whether Gogs is mounted at "/" or behind a reverse proxy on a // prefix like "/gogs". Pass paths that start with "/" (e.g. "/user/login"). // The result is canonicalized by trimming trailing slashes, so subUrl("/") // returns "/gogs" (or "" at root), letting callers compare against // location.pathname without juggling both "/gogs" and "/gogs/" forms. export function subUrl(path: string): string { const url = webContext.subURL + path; return url.length > 1 ? url.replace(/\/+$/, "") : url; }