mirror of https://github.com/omar-polo/gmid.git
trim initial forward slashes
this parse gemini://example.com///foo into an IRI whose path is "foo". I'm not 100% this is standard-compliant but: 1. it seems a logical consequence of the URI/IRI cleaning algo (where we drop sequential slashes) 2. practically speaking serving file a sequence of forward slashes doesn't really make sense, even in the case of CGI scripts
This commit is contained in:
parent
f77a8c867e
commit
42bbdc7978
4
iri.c
4
iri.c
|
@ -293,6 +293,10 @@ parse_path(struct parser *p)
|
|||
{
|
||||
char c;
|
||||
|
||||
/* trim initial slashes */
|
||||
while (*p->iri == '/')
|
||||
p->iri++;
|
||||
|
||||
p->parsed->path = p->iri;
|
||||
if (*p->iri == '\0') {
|
||||
p->parsed->query = p->parsed->fragment = p->iri;
|
||||
|
|
|
@ -169,6 +169,14 @@ main(void)
|
|||
PASS,
|
||||
IRI("gemini", "omarpolo.com", "", "", "", ""),
|
||||
"parse path with lots of cleaning available");
|
||||
TEST("gemini://omarpolo.com//foo",
|
||||
PASS,
|
||||
IRI("gemini", "omarpolo.com", "", "foo", "", ""),
|
||||
"Trim initial slashes");
|
||||
TEST("gemini://omarpolo.com/////foo",
|
||||
PASS,
|
||||
IRI("gemini", "omarpolo.com", "", "foo", "", ""),
|
||||
"Trim initial slashes (pt. 2)");
|
||||
|
||||
/* query */
|
||||
TEST("foo://example.com/foo/?gne",
|
||||
|
|
Loading…
Reference in New Issue