aboutsummaryrefslogtreecommitdiff
path: root/iri.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-21 22:48:16 +0000
committerOmar Polo <op@omarpolo.com>2021-01-21 22:48:16 +0000
commit42bbdc7978acc6be9beb5baa7d94fedb7c211b49 (patch)
tree9184f10e29ac2182f518831796829a7470ad7fc2 /iri.c
parentf77a8c867ecc2881d60345b9e1b1ee4259189e9a (diff)
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
Diffstat (limited to 'iri.c')
-rw-r--r--iri.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/iri.c b/iri.c
index 26ee920..beba368 100644
--- a/iri.c
+++ b/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;