@bgord/ui 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function absoluteUrl(path: string, request: Request | null): string | URL;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function absoluteUrl(path, request) {
|
|
2
|
+
if (!request)
|
|
3
|
+
return path;
|
|
4
|
+
const incoming = new URL(request.url);
|
|
5
|
+
// Respect reverse-proxy TLS
|
|
6
|
+
const xfproto = request.headers.get("x-forwarded-proto");
|
|
7
|
+
const forwarded = request.headers.get("forwarded");
|
|
8
|
+
const isHttps = xfproto === "https" || (forwarded && /proto=https/i.test(forwarded));
|
|
9
|
+
// Build a clean origin (protocol + host), no path/search/hash
|
|
10
|
+
const origin = `${isHttps ? "https:" : incoming.protocol}//${incoming.host}`;
|
|
11
|
+
// Let WHATWG URL do the right thing:
|
|
12
|
+
// - if `path` is relative with "?...", it becomes pathname + search (NO %3F)
|
|
13
|
+
// - if `path` is absolute, it’s used as-is
|
|
14
|
+
return new URL(path, origin);
|
|
15
|
+
}
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
package/package.json
CHANGED