Files
gluetun/internal/updater/providers/vyprvpn/filename.go
Quentin McGaw e8e7b83297 Maintenance: refactor servers updater code
- Require at least 80% of number of servers now to pass
- Each provider is in its own package with a common structure
- Unzip package with unzipper interface
- Openvpn package with extraction and download functions
2021-05-08 00:59:42 +00:00

23 lines
459 B
Go

package vyprvpn
import (
"errors"
"fmt"
"strings"
)
var errNotOvpnExt = errors.New("filename does not have the openvpn file extension")
func parseFilename(fileName string) (
region string, err error,
) {
const suffix = ".ovpn"
if !strings.HasSuffix(fileName, suffix) {
return "", fmt.Errorf("%w: %s", errNotOvpnExt, fileName)
}
region = strings.TrimSuffix(fileName, suffix)
region = strings.ReplaceAll(region, " - ", " ")
return region, nil
}