1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 07:39:41 +02:00

add support for meta tags on share pages (#867)

This commit is contained in:
Hayden 2021-12-06 17:14:14 -09:00 committed by GitHub
parent 5454d2c8b8
commit 5839992c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 190 additions and 118 deletions

View file

@ -2,6 +2,24 @@ export const useAsyncKey = function () {
return String(Date.now());
};
export function detectServerBaseUrl(req: any) {
if (!req || req === undefined) {
return "";
}
if (req.headers.referer) {
const url = new URL(req.headers.referer);
return `${url.protocol}//${url.host}`;
} else if (req.headers.host) {
const protocol = req.connection.encrypted ? "https" : "http:";
return `${protocol}//${req.headers.host}`;
} else if (req.connection.remoteAddress) {
const protocol = req.connection.encrypted ? "https" : "http:";
return `${protocol}//${req.connection.localAddress}:${req.connection.localPort}`;
}
return "";
}
export function uuid4() {
// @ts-ignore
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>