mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 09:29:18 +08:00 
			
		
		
		
	Simplify the logic in the previous commit
This commit is contained in:
		@ -298,18 +298,16 @@ func sortRoutes(routes []ConfigValue) {
 | 
				
			|||||||
				jPM = pathMatcher
 | 
									jPM = pathMatcher
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// if there is only one path in the matcher, sort by
 | 
								// sort by longer path (more specific) first; missing
 | 
				
			||||||
			// longer path (more specific) first; if one of the
 | 
								// path matchers are treated as zero-length paths
 | 
				
			||||||
			// routes doesn't have a matcher, then it's treated
 | 
								var iPathLen, jPathLen int
 | 
				
			||||||
			// like a zero-length path matcher
 | 
								if iPM != nil {
 | 
				
			||||||
			switch {
 | 
									iPathLen = len(iPM[0])
 | 
				
			||||||
			case iPM == nil && jPM != nil:
 | 
					 | 
				
			||||||
				return false
 | 
					 | 
				
			||||||
			case iPM != nil && jPM == nil:
 | 
					 | 
				
			||||||
				return true
 | 
					 | 
				
			||||||
			case iPM != nil && jPM != nil:
 | 
					 | 
				
			||||||
				return len(iPM[0]) > len(jPM[0])
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if jPM != nil {
 | 
				
			||||||
 | 
									jPathLen = len(jPM[0])
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return iPathLen > jPathLen
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return dirPositions[iDir] < dirPositions[jDir]
 | 
							return dirPositions[iDir] < dirPositions[jDir]
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user