(ctx context.Context, parts []string)
| 53 | } |
| 54 | |
| 55 | func (p *Parser) decodePlainURL(ctx context.Context, parts []string) (string, string, error) { |
| 56 | var format string |
| 57 | |
| 58 | encoded := strings.Join(parts, "/") |
| 59 | urlParts := strings.Split(encoded, "@") |
| 60 | |
| 61 | if len(urlParts[0]) == 0 { |
| 62 | return "", "", newInvalidURLError(ctx, "Image URL is empty") |
| 63 | } |
| 64 | |
| 65 | if len(urlParts) > 2 { |
| 66 | return "", "", newInvalidURLError(ctx, "Multiple formats are specified: %s", encoded) |
| 67 | } |
| 68 | |
| 69 | if len(urlParts) == 2 && len(urlParts[1]) > 0 { |
| 70 | format = urlParts[1] |
| 71 | } |
| 72 | |
| 73 | unescaped, err := url.PathUnescape(urlParts[0]) |
| 74 | if err != nil { |
| 75 | return "", "", newInvalidURLError(ctx, "Invalid url encoding: %s", encoded) |
| 76 | } |
| 77 | |
| 78 | return p.preprocessURL(unescaped), format, nil |
| 79 | } |
| 80 | |
| 81 | func (p *Parser) DecodeURL( |
| 82 | ctx context.Context, |
no test coverage detected