Skip to content

Commit

Permalink
fix: relax scheme check for origins (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Apr 19, 2023
1 parent 96ae098 commit 94f2d44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
8 changes: 0 additions & 8 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"go.uber.org/zap"
)

var errInvalidOrigin = errors.New(`invalid origin, the URL must ward with "https", "http" or "capacitor"`)

// ErrUnsupportedProtocolVersion is returned when the version passed is unsupported.
var ErrUnsupportedProtocolVersion = errors.New("compatibility mode only supports protocol version 7")

Expand Down Expand Up @@ -168,12 +166,6 @@ func validateOrigins(origins []string) error {
u.Fragment != "" {
return fmt.Errorf(`invalid origin, must be a URL having only a scheme, a host and optionally a port, "*" or "null": %w`, err)
}

switch u.Scheme {
case "http", "https", "capacitor":
default:
return errInvalidOrigin
}
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ func TestOriginsValidator(t *testing.T) {
{"null", "https://example.com:3000"},
{"capacitor://"},
{"capacitor://www.example.com"},
{"ionic://"},
{"foobar://"},
}

invalidOrigins := [][]string{
{"f"},
{"foo"},
{"https://example.com", "bar"},
{"ftp://example.com"},
{"https://example.com/"},
{"https://user@example.com"},
{"https://example.com:abc"},
Expand Down

0 comments on commit 94f2d44

Please sign in to comment.