Skip to content
Snippets Groups Projects
Commit dddf3369 authored by ko_oler's avatar ko_oler
Browse files

Parse -> ParseActionURL (заменена на функцию)

parent d6d2c545
No related branches found
No related tags found
No related merge requests found
...@@ -130,23 +130,25 @@ func (p *ParsedActionURL) GetScheme() string { ...@@ -130,23 +130,25 @@ func (p *ParsedActionURL) GetScheme() string {
return p.scheme return p.scheme
} }
func (p *ParsedActionURL) Parse(action string) error { func ParseActionURL(action string) (*ParsedActionURL, error) {
u, err := url.Parse(action) u, err := url.Parse(action)
if err != nil { if err != nil {
return err return nil, err
} }
p.scheme = u.Scheme parsed := &ParsedActionURL{}
if p.GetScheme() == "grpc" { parsed.scheme = u.Scheme
if parsed.GetScheme() == "grpc" {
path := u.Path path := u.Path
if strings.HasPrefix(u.Path, "/") { if strings.HasPrefix(u.Path, "/") {
path = u.Path[1:] path = u.Path[1:]
} }
splitPath := strings.Split(path, "/") splitPath := strings.Split(path, "/")
if len(splitPath) < 2 { if len(splitPath) < 2 {
return errors.Errorf("incorrect action URL, no action id: '%s'", action) return nil, errors.Errorf("incorrect action URL, no action id: '%s'", action)
} }
p.extensionID = splitPath[0] parsed.extensionID = splitPath[0]
p.actionID = splitPath[1] parsed.actionID = splitPath[1]
} }
return nil return nil, nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment