Handle Mastodon-generated links for targets starting with “www.” properly
This commit is contained in:
		
							parent
							
								
									df866a464d
								
							
						
					
					
						commit
						6600da0f7b
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -54,7 +54,7 @@ const isLinkMisleading = (link, checkUrlLike = true) => { | ||||||
|   const targetURL = new URL(link.href); |   const targetURL = new URL(link.href); | ||||||
| 
 | 
 | ||||||
|   // The following may not work with international domain names
 |   // The following may not work with international domain names
 | ||||||
|   if (linkText === targetURL.origin || linkText === targetURL.host || 'www.' + linkText === targetURL.host || linkText.startsWith(targetURL.origin + '/') || linkText.startsWith(targetURL.host + '/')) { |   if (linkText === targetURL.origin || linkText === targetURL.host || 'www.' + linkText === targetURL.host || linkText.startsWith(targetURL.origin + '/') || linkText.startsWith(targetURL.host + '/') || ('www.' + linkText).startsWith(targetURL.host + '/')) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -62,7 +62,7 @@ const isLinkMisleading = (link, checkUrlLike = true) => { | ||||||
|   const hostname = decodeIDNA(targetURL.hostname); |   const hostname = decodeIDNA(targetURL.hostname); | ||||||
|   const host = targetURL.host.replace(targetURL.hostname, hostname); |   const host = targetURL.host.replace(targetURL.hostname, hostname); | ||||||
|   const origin = targetURL.origin.replace(targetURL.host, host); |   const origin = targetURL.origin.replace(targetURL.host, host); | ||||||
|   if (linkText === origin || linkText === host || linkText.startsWith(origin + '/') || linkText.startsWith(host + '/')) { |   if (linkText === origin || linkText === host || 'www.' + linkText === host || linkText.startsWith(origin + '/') || linkText.startsWith(host + '/') || ('www.' + linkText).startsWith(host + '/')) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue