File tree Expand file tree Collapse file tree
packages/core-internal/src/validators Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,8 +115,17 @@ function ipv6LiteralFromHost(host: string): string | undefined {
115115 return host . startsWith ( '[' ) && host . endsWith ( ']' ) ? host . slice ( 1 , - 1 ) : undefined ;
116116}
117117
118+ function stripTrailingDnsRootDots ( host : string ) : string {
119+ let end = host . length ;
120+ while ( end > 0 && host . codePointAt ( end - 1 ) === 46 ) {
121+ end -- ;
122+ }
123+
124+ return end === host . length ? host : host . slice ( 0 , end ) ;
125+ }
126+
118127function normalizeHostForPolicy ( host : string ) : string {
119- return ipv6LiteralFromHost ( host ) === undefined ? host . replace ( / \. + $ / , '' ) : host ;
128+ return ipv6LiteralFromHost ( host ) === undefined ? stripTrailingDnsRootDots ( host ) : host ;
120129}
121130
122131function isBlockedIPv6Literal ( host : string ) : boolean {
You can’t perform that action at this time.
0 commit comments