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 {
return p.scheme
}
func (p *ParsedActionURL) Parse(action string) error {
func ParseActionURL(action string) (*ParsedActionURL, error) {
u, err := url.Parse(action)
if err != nil {
return err
return nil, err
}
p.scheme = u.Scheme
if p.GetScheme() == "grpc" {
parsed := &ParsedActionURL{}
parsed.scheme = u.Scheme
if parsed.GetScheme() == "grpc" {
path := u.Path
if strings.HasPrefix(u.Path, "/") {
path = u.Path[1:]
}
splitPath := strings.Split(path, "/")
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]
p.actionID = splitPath[1]
parsed.extensionID = splitPath[0]
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.
Finish editing this message first!
Please register or to comment