* Change PostgreSQL connstring parsing to handle IPv6 * Fix used variable * Remove redundant code + use variable
This commit is contained in:
		
							parent
							
								
									7551141dbe
								
							
						
					
					
						commit
						4296427214
					
				| 
						 | 
					@ -114,12 +114,12 @@ func getEngine() (*xorm.Engine, error) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "postgres":
 | 
						case "postgres":
 | 
				
			||||||
		host, port := "127.0.0.1", "5432"
 | 
							host, port := "127.0.0.1", "5432"
 | 
				
			||||||
		fields := strings.Split(DbCfg.Host, ":")
 | 
							if strings.Contains(DbCfg.Host, ":") && !strings.HasSuffix(DbCfg.Host, "]") {
 | 
				
			||||||
		if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 {
 | 
								idx := strings.LastIndex(DbCfg.Host, ":")
 | 
				
			||||||
			host = fields[0]
 | 
								host = DbCfg.Host[:idx]
 | 
				
			||||||
		}
 | 
								port = DbCfg.Host[idx+1:]
 | 
				
			||||||
		if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 {
 | 
							} else if len(DbCfg.Host) > 0 {
 | 
				
			||||||
			port = fields[1]
 | 
								host = DbCfg.Host
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if host[0] == '/' { // looks like a unix socket
 | 
							if host[0] == '/' { // looks like a unix socket
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue