fix: skip empty query keys
This commit is contained in:
		
							parent
							
								
									8bc33130a9
								
							
						
					
					
						commit
						48eb9f8e3c
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		|  | @ -26,6 +26,12 @@ impl URL { | ||||||
|                 Some(key) => key.to_string(), |                 Some(key) => key.to_string(), | ||||||
|                 None => continue, |                 None => continue, | ||||||
|             }; |             }; | ||||||
|  |             // Skip empty keys should they appear
 | ||||||
|  |             if key.len() == 0 { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|             let value = key_value |             let value = key_value | ||||||
|                 .next() |                 .next() | ||||||
|                 .unwrap_or("") |                 .unwrap_or("") | ||||||
|  | @ -125,6 +131,7 @@ mod tests { | ||||||
| 
 | 
 | ||||||
|         let url = URL::new("/path/to/resource".to_string()).unwrap(); |         let url = URL::new("/path/to/resource".to_string()).unwrap(); | ||||||
|         assert_eq!(url.path, "/path/to/resource"); |         assert_eq!(url.path, "/path/to/resource"); | ||||||
|  |         assert_eq!(url.query.len(), 0); | ||||||
| 
 | 
 | ||||||
|         let url = URL::new("/path/to/resource?query=string".to_string()).unwrap(); |         let url = URL::new("/path/to/resource?query=string".to_string()).unwrap(); | ||||||
|         assert_eq!(url.path, "/path/to/resource"); |         assert_eq!(url.path, "/path/to/resource"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue