From c16c86bcc01dff2a984aeffd58e2402a876cc12d Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 24 Jul 2018 02:27:48 +0200 Subject: make: handle empty prefixes properly still needs to add integration tests --- src/blogc-make/atom.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/blogc-make/atom.c') diff --git a/src/blogc-make/atom.c b/src/blogc-make/atom.c index d5f5387..0e4e631 100644 --- a/src/blogc-make/atom.c +++ b/src/blogc-make/atom.c @@ -20,11 +20,11 @@ static const char atom_template[] = "\n" " {{ SITE_TITLE }}{%% ifdef FILTER_TAG %%} - " "{{ FILTER_TAG }}{%% endif %%}\n" - " {{ BASE_URL }}/%s{%% ifdef FILTER_TAG %%}/{{ FILTER_TAG }}" + " {{ BASE_URL }}%s%s{%% ifdef FILTER_TAG %%}/{{ FILTER_TAG }}" "{%% endif %%}%s\n" " {{ DATE_FIRST_FORMATTED }}\n" " \n" - " \n" " \n" " {{ AUTHOR_NAME }}\n" @@ -34,10 +34,10 @@ static const char atom_template[] = " {%% block listing %%}\n" " \n" " {{ TITLE }}\n" - " {{ BASE_URL }}/%s/{{ FILENAME }}/\n" + " {{ BASE_URL }}%s%s/{{ FILENAME }}/\n" " {{ DATE_FORMATTED }}\n" " {{ DATE_FORMATTED }}\n" - " \n" + " \n" " \n" " {{ AUTHOR_NAME }}\n" " {{ AUTHOR_EMAIL }}\n" @@ -66,9 +66,12 @@ bm_atom_deploy(bm_settings_t *settings, bc_error_t **err) const char *atom_prefix = bc_trie_lookup(settings->settings, "atom_prefix"); const char *atom_ext = bc_trie_lookup(settings->settings, "atom_ext"); const char *post_prefix = bc_trie_lookup(settings->settings, "post_prefix"); + const char *atom_slash = atom_prefix[0] == '\0' ? "" : "/"; + const char *post_slash = post_prefix[0] == '\0' ? "" : "/"; - char *content = bc_strdup_printf(atom_template, atom_prefix, atom_ext, - atom_prefix, atom_ext, post_prefix, post_prefix); + char *content = bc_strdup_printf(atom_template, atom_slash, atom_prefix, + atom_ext, atom_slash, atom_prefix, atom_ext, post_slash, post_prefix, + post_slash, post_prefix); if (-1 == write(fd, content, strlen(content))) { *err = bc_error_new_printf(BLOGC_MAKE_ERROR_ATOM, -- cgit v1.2.3-18-g5258