This repository was archived by the owner on Nov 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -188,10 +188,11 @@ function updateState () {
188188 return ;
189189 }
190190
191+ // tabUrl.host instead of hostname should be used to show the "disabled" status properly (#19293)
191192 const tabUrl = new URL ( tabs [ 0 ] . url ) ;
192- const hostname = util . getNormalisedHostname ( tabUrl . hostname ) ;
193+ const host = util . getNormalisedHostname ( tabUrl . host ) ;
193194
194- if ( isExtensionDisabledOnSite ( hostname ) || iconState == "disabled" ) {
195+ if ( isExtensionDisabledOnSite ( host ) || iconState == "disabled" ) {
195196 if ( 'setIcon' in chrome . browserAction ) {
196197 chrome . browserAction . setIcon ( {
197198 path : {
Original file line number Diff line number Diff line change @@ -62,11 +62,16 @@ function loadExtensionFile(url, returnType) {
6262
6363/**
6464 * Remove tailing dots from hostname, e.g. "www.example.com."
65+ * Preserve port numbers if they are used
6566 */
66- function getNormalisedHostname ( hostname ) {
67+ function getNormalisedHostname ( host ) {
68+ let [ hostname , port ] = host . split ( ":" ) ;
6769 while ( hostname && hostname [ hostname . length - 1 ] === '.' && hostname !== '.' ) {
6870 hostname = hostname . slice ( 0 , - 1 ) ;
6971 }
72+ if ( port ) {
73+ return `${ hostname } :${ port } ` ;
74+ }
7075 return hostname ;
7176}
7277
Original file line number Diff line number Diff line change @@ -49,9 +49,16 @@ describe('util.js', function() {
4949 } ) ;
5050
5151 describe ( 'getNormalisedHostname' , function ( ) {
52- it ( 'removes tailing dots' , function ( ) {
52+ it ( 'preserve port numbers' , function ( ) {
53+ assert . strictEqual ( util . getNormalisedHostname ( 'example.com' ) , 'example.com' ) ;
54+ assert . strictEqual ( util . getNormalisedHostname ( 'example.com:8080' ) , 'example.com:8080' ) ;
55+ } ) ;
56+
57+ it ( 'removes tailing dots and preserve port numbers' , function ( ) {
5358 assert . strictEqual ( util . getNormalisedHostname ( 'example.com.' ) , 'example.com' ) ;
59+ assert . strictEqual ( util . getNormalisedHostname ( 'example.com.:8080' ) , 'example.com:8080' ) ;
5460 assert . strictEqual ( util . getNormalisedHostname ( 'example.com..' ) , 'example.com' ) ;
61+ assert . strictEqual ( util . getNormalisedHostname ( 'example.com..:8080' ) , 'example.com:8080' ) ;
5562 } ) ;
5663
5764 it ( 'preserves a single dot' , function ( ) {
You can’t perform that action at this time.
0 commit comments