File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,27 @@ import type { Metric } from 'next/app';
33const DEFAULT_ENDPOINT = '/observability/web-vitals' ;
44const APP_LABEL = process . env . NEXT_PUBLIC_WEB_VITALS_APP ?? 'frontend' ;
55
6+ function normalizeProtocol ( protocol : string | undefined ) : string | undefined {
7+ if ( protocol === undefined ) {
8+ return undefined ;
9+ }
10+
11+ const trimmedProtocol = protocol . trim ( ) ;
12+
13+ if ( ! trimmedProtocol ) {
14+ return undefined ;
15+ }
16+
17+ return trimmedProtocol . endsWith ( ':' ) ? trimmedProtocol : `${ trimmedProtocol } :` ;
18+ }
19+
620function buildEndpoint ( ) : string {
721 if ( typeof window === 'undefined' ) {
822 return DEFAULT_ENDPOINT ;
923 }
1024
11- const protocol = process . env . NEXT_PUBLIC_BACKEND_PROTOCOL ?? window . location . protocol ?? 'http:' ;
25+ const normalizedProtocol = normalizeProtocol ( process . env . NEXT_PUBLIC_BACKEND_PROTOCOL ) ;
26+ const protocol = normalizedProtocol ?? window . location . protocol ?? 'http:' ;
1227 const host = process . env . NEXT_PUBLIC_BACKEND_HOST ?? window . location . hostname ;
1328 const port = process . env . NEXT_PUBLIC_BACKEND_PORT ?? '' ;
1429 const endpoint = process . env . NEXT_PUBLIC_WEB_VITALS_ENDPOINT ?? DEFAULT_ENDPOINT ;
You can’t perform that action at this time.
0 commit comments