MCPcopy Create free account
hub / github.com/MMadmer/EpicAssetsNotifyBot / normalizeDatabaseURL

Function normalizeDatabaseURL

internal/store/sqlite/store.go:549–578  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

547}
548
549func normalizeDatabaseURL(raw string) (string, error) {
550 value := strings.TrimSpace(raw)
551 if value == "" {
552 return "", errors.New("database url is empty")
553 }
554
555 switch {
556 case strings.HasPrefix(value, "sqlite+aiosqlite:///"):
557 value = strings.TrimPrefix(value, "sqlite+aiosqlite:///")
558 case strings.HasPrefix(value, "sqlite:///"):
559 value = strings.TrimPrefix(value, "sqlite:///")
560 case strings.HasPrefix(value, "file:"):
561 value = strings.TrimPrefix(value, "file:")
562 }
563
564 if value == ":memory:" {
565 return "file::memory:?cache=shared", nil
566 }
567
568 path := filepath.FromSlash(value)
569 if !filepath.IsAbs(path) {
570 abs, err := filepath.Abs(path)
571 if err != nil {
572 return "", fmt.Errorf("resolve database path: %w", err)
573 }
574 path = abs
575 }
576
577 return "file:" + filepath.ToSlash(path), nil
578}

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected