Merge pull request #5 from samyakbardiya/fix/handle-non-alphanumeric-chars
fix: Handle non-alphanumeric characters in bangs
This commit is contained in:
		
						commit
						f96ce5706d
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -55,13 +55,13 @@ function getBangredirectUrl() {
 | 
			
		|||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const match = query.match(/!([a-z0-9]+)/i);
 | 
			
		||||
  const match = query.match(/!(\S+)/i);
 | 
			
		||||
 | 
			
		||||
  const bangCandidate = match?.[1]?.toLowerCase();
 | 
			
		||||
  const selectedBang = bangs.find((b) => b.t === bangCandidate) ?? defaultBang;
 | 
			
		||||
 | 
			
		||||
  // Remove the first bang from the query
 | 
			
		||||
  const cleanQuery = query.replace(/![a-z0-9]+\s*/i, "").trim();
 | 
			
		||||
  const cleanQuery = query.replace(/!\S+\s*/i, "").trim();
 | 
			
		||||
 | 
			
		||||
  // Format of the url is:
 | 
			
		||||
  // https://www.google.com/search?q={{{s}}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue