6989a98d75
- Arkitektur: docs/auth/passwordless-architecture.md - Backend: iom/quixzoom-auth-service/ (FastAPI + Redis) - Webb: quixzoom-market-pages/se/login/ (QR-kod + polling) - App: iom/quixzoom-app/src/features/auth/ (push + deep links) Flöde: QR-kod → app-godkännande → webb-inloggad
18 lines
670 B
JavaScript
18 lines
670 B
JavaScript
import { URL } from 'url';
|
|
export function createUrl({ protocol, host, port, path }) {
|
|
// wrap IPv6 host in brackets
|
|
const ipv6Host = host?.includes(':') ? `[${host}]` : host;
|
|
// use fallback values to create a valid URL (protocol: 'undefined:', host: '[::]')
|
|
// nock v13 issue: protocol and host are undefined (https://github.com/chimurai/http-proxy-middleware/issues/1035)
|
|
// nock v14+ seems to return protocol and host correctly
|
|
const base = `${protocol || 'undefined:'}//${ipv6Host || '[::]'}`;
|
|
const url = new URL(base);
|
|
if (port) {
|
|
url.port = port;
|
|
}
|
|
if (path) {
|
|
url.pathname = path;
|
|
}
|
|
return url;
|
|
}
|