Fix twitter regexp for comments by removing anchor
This commit is contained in:
		
							parent
							
								
									6a4892944b
								
							
						
					
					
						commit
						fcd6cf66bc
					
				
							
								
								
									
										6
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.go
									
									
									
									
									
								
							| @ -18,7 +18,7 @@ type NostrClient struct { | ||||
| } | ||||
| 
 | ||||
| var ( | ||||
| 	TwitterUrlRegexp = regexp.MustCompile(`^(?:https?:\/\/)?((www\.)?(twitter|x)\.com)\/`) | ||||
| 	TwitterUrlRegexp = regexp.MustCompile(`(?:https?:\/\/)?(?:www\.)?((?:twitter|x)\.com)\/\w+\/status(?:es)?\/\d+`) | ||||
| 	// references: | ||||
| 	// - https://github.com/zedeus/nitter/wiki/Instances | ||||
| 	// - https://status.d420.de/ | ||||
| @ -57,9 +57,9 @@ func main() { | ||||
| 			var comment string | ||||
| 
 | ||||
| 			if m = TwitterUrlRegexp.FindStringSubmatch(item.Url); m != nil { | ||||
| 				comment = strings.Replace(item.Url, m[1], "xcancel.com", 1) | ||||
| 				comment = strings.Replace(m[0], m[1], "xcancel.com", 1) | ||||
| 			} else if m = TwitterUrlRegexp.FindStringSubmatch(item.Text); m != nil { | ||||
| 				comment = strings.Replace(item.Text, m[1], "xcancel.com", 1) | ||||
| 				comment = strings.Replace(m[0], m[1], "xcancel.com", 1) | ||||
| 			} | ||||
| 
 | ||||
| 			if comment != "" { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user