mirror of
https://github.com/openziti/zrok.git
synced 2025-06-26 04:31:30 +02:00
apiEndpoint validation tweaks (#260)
This commit is contained in:
parent
1c39fd5f3e
commit
6e17f4df3a
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,7 @@
|
|||||||
*.db
|
*.db
|
||||||
automated-release-build
|
automated-release-build
|
||||||
etc/dev.yml
|
etc/dev.yml
|
||||||
|
etc/dev-metrics.yml
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
/node_modules/
|
/node_modules/
|
||||||
@ -28,3 +29,4 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
.obsidian
|
||||||
|
@ -44,14 +44,12 @@ func (cmd *configSetCommand) run(_ *cobra.Command, args []string) {
|
|||||||
if zrd.Cfg == nil {
|
if zrd.Cfg == nil {
|
||||||
zrd.Cfg = &zrokdir.Config{}
|
zrd.Cfg = &zrokdir.Config{}
|
||||||
}
|
}
|
||||||
ok, err := isValidUrl(value)
|
ok, err := isFullyValidUrl(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("unable to validate api endpoint")
|
tui.Error("unable to validate api endpoint", err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println("invalid apiEndpoint, please make sure scheme and host is provided")
|
tui.Error("invalid apiEndpoint; please make sure URL starts with http:// or https://", nil)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
zrd.Cfg.ApiEndpoint = value
|
zrd.Cfg.ApiEndpoint = value
|
||||||
modified = true
|
modified = true
|
||||||
@ -74,7 +72,7 @@ func (cmd *configSetCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidUrl(rawUrl string) (bool, error) {
|
func isFullyValidUrl(rawUrl string) (bool, error) {
|
||||||
u, err := url.Parse(rawUrl)
|
u, err := url.Parse(rawUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user