code.gitea.io/gitea@v1.19.3/modules/nosql/leveldb.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package nosql
     5  
     6  import "net/url"
     7  
     8  // ToLevelDBURI converts old style connections to a LevelDBURI
     9  //
    10  // A LevelDBURI matches the pattern:
    11  //
    12  // leveldb://path[?[option=value]*]
    13  //
    14  // We have previously just provided the path but this prevent other options
    15  func ToLevelDBURI(connection string) *url.URL {
    16  	uri, err := url.Parse(connection)
    17  	if err == nil && uri.Scheme == "leveldb" {
    18  		return uri
    19  	}
    20  	uri, _ = url.Parse("leveldb://common")
    21  	uri.Host = ""
    22  	uri.Path = connection
    23  	return uri
    24  }