github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/nosql/leveldb.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package nosql 7 8 import "net/url" 9 10 // ToLevelDBURI converts old style connections to a LevelDBURI 11 // 12 // A LevelDBURI matches the pattern: 13 // 14 // leveldb://path[?[option=value]*] 15 // 16 // We have previously just provided the path but this prevent other options 17 func ToLevelDBURI(connection string) *url.URL { 18 uri, err := url.Parse(connection) 19 if err == nil && uri.Scheme == "leveldb" { 20 return uri 21 } 22 uri, _ = url.Parse("leveldb://common") 23 uri.Host = "" 24 uri.Path = connection 25 return uri 26 }