]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-snapshot.c
ui-shared: currenturl should take into account leading slash
[ps-cgit] / ui-snapshot.c
index 3107b055dbc00ff5ad785b90896165e5cd1dfbdc..cb34f4b59c84cc61aeef210095bec9118537524a 100644 (file)
@@ -99,7 +99,7 @@ static const struct cgit_snapshot_format *get_format(const char *filename)
        const struct cgit_snapshot_format *fmt;
 
        for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
-               if (!suffixcmp(filename, fmt->suffix))
+               if (ends_with(filename, fmt->suffix))
                        return fmt;
        }
        return NULL;
@@ -119,6 +119,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
                cgit_print_error("Not a commit reference: %s", hex);
                return 1;
        }
+       ctx.page.etag = sha1_to_hex(sha1);
        ctx.page.mimetype = xstrdup(format->mimetype);
        ctx.page.filename = xstrdup(filename);
        cgit_print_http_headers();
@@ -151,7 +152,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
                goto out;
 
        reponame = cgit_repobasename(url);
-       if (prefixcmp(snapshot.buf, reponame) == 0) {
+       if (starts_with(snapshot.buf, reponame)) {
                const char *new_start = snapshot.buf;
                new_start += strlen(reponame);
                while (new_start && (*new_start == '-' || *new_start == '_'))