| 1 | #ifndef URL_H |
| 2 | #define URL_H |
| 3 | |
| 4 | struct strbuf; |
| 5 | |
| 6 | int is_url(const char *url); |
| 7 | int is_urlschemechar(int first_flag, int ch); |
| 8 | char *url_decode(const char *url); |
| 9 | char *url_decode_mem(const char *url, int len); |
| 10 | |
| 11 | /* |
| 12 | * Similar to the url_decode_{,mem} methods above, but doesn't assume there |
| 13 | * is a scheme followed by a : at the start of the string. Instead, %-sequences |
| 14 | * before any : are also parsed. |
| 15 | */ |
| 16 | char *url_percent_decode(const char *encoded); |
| 17 | |
| 18 | char *url_decode_parameter_name(const char **query); |
| 19 | char *url_decode_parameter_value(const char **query); |
| 20 | |
| 21 | void end_url_with_slash(struct strbuf *buf, const char *url); |
| 22 | void str_end_url_with_slash(const char *url, char **dest); |
| 23 | |
| 24 | int url_is_local_not_ssh(const char *url); |
| 25 | |
| 26 | enum url_scheme { |
| 27 | URL_SCHEME_UNKNOWN = 0, |
| 28 | URL_SCHEME_LOCAL, |
| 29 | URL_SCHEME_FILE, |
| 30 | URL_SCHEME_SSH, |
| 31 | URL_SCHEME_GIT, |
| 32 | }; |
| 33 | |
| 34 | /* |
| 35 | * Identify the URL scheme by name. Returns URL_SCHEME_UNKNOWN |
| 36 | * if the name does not match any scheme that Git knows about. |
| 37 | */ |
| 38 | enum url_scheme url_get_scheme(const char *name); |
| 39 | |
| 40 | /* |
| 41 | * The set of unreserved characters as per STD66 (RFC3986) is |
| 42 | * '[A-Za-z0-9-._~]'. These characters are safe to appear in URI |
| 43 | * components without percent-encoding. |
| 44 | */ |
| 45 | int is_rfc3986_unreserved(char ch); |
| 46 | |
| 47 | /* |
| 48 | * This is a variant of is_rfc3986_unreserved() that treats uppercase |
| 49 | * letters as "reserved". This forces them to be percent-encoded, allowing |
| 50 | * 'Foo' (%46oo) and 'foo' (foo) to be distinct on case-folding filesystems. |
| 51 | */ |
| 52 | int is_casefolding_rfc3986_unreserved(char c); |
| 53 | |
| 54 | #endif /* URL_H */ |