author | Olivier Brunel
<jjk@jjacky.com> 2023-01-01 20:37:32 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-01-01 20:37:32 UTC |
parent | 687936052dd5795bdf987df8998b68fbf59b1df1 |
main.c | +6 | -2 |
diff --git a/main.c b/main.c index 77fd17c..533a293 100644 --- a/main.c +++ b/main.c @@ -968,9 +968,13 @@ load_page_from_file(const char *file, struct page *page, stralloc *sa) page->fd = open_read(file); if (page->fd < 0) strerr_diefu3sys(-ERR_IO, "open '", file, "'"); - size_t l = strlen(file); + const char *s = strrchr(file, '/'); + if (!s) s = file; + else ++s; + + size_t l = strlen(s); page->fileoff = sa->len; - if (!stralloc_catb(sa, file, l - 2) + if (!stralloc_catb(sa, s, l - 2) || !stralloc_catb(sa, "html", 5)) strerr_diefu3sys(-ERR_MEM, "load page title from '", file, "'");