feat(providers): add giganews support (#2479)
This commit is contained in:
22
internal/provider/giganews/updater/filename.go
Normal file
22
internal/provider/giganews/updater/filename.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package updater
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user