mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-30 18:22:49 -04:00 
			
		
		
		
	Merge pull request #899 from abiosoft/master
Minor refactor for rewrite.
This commit is contained in:
		
						commit
						fd8fe24bcb
					
				| @ -28,17 +28,13 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl | |||||||
| 			query = tparts[1] | 			query = tparts[1] | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		// add trailing slash for directories, if present | ||||||
| 		if strings.HasSuffix(tparts[0], "/") && !strings.HasSuffix(t, "/") { | 		if strings.HasSuffix(tparts[0], "/") && !strings.HasSuffix(t, "/") { | ||||||
| 			t += "/" | 			t += "/" | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// add trailing slash for directories, if present |  | ||||||
| 		if strings.HasSuffix(v, "/") && !strings.HasSuffix(t, "/") { |  | ||||||
| 			t += "/" |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		// validate file | 		// validate file | ||||||
| 		if isValidFile(fs, t) { | 		if validFile(fs, t) { | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -70,9 +66,9 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl | |||||||
| 	return RewriteDone | 	return RewriteDone | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // isValidFile checks if file exists on the filesystem. | // validFile checks if file exists on the filesystem. | ||||||
| // if file ends with `/`, it is validated as a directory. | // if file ends with `/`, it is validated as a directory. | ||||||
| func isValidFile(fs http.FileSystem, file string) bool { | func validFile(fs http.FileSystem, file string) bool { | ||||||
| 	if fs == nil { | 	if fs == nil { | ||||||
| 		return false | 		return false | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user