From 87ffebd7376fbf5bc22d301f16498d1d88861643 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Tue, 23 Oct 2018 18:53:08 -0700 Subject: [PATCH] Fix #14: Do not add a slash between path and filename Signed-off-by: James Ketrenos --- frontend/elements/photo-lightbox.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/elements/photo-lightbox.html b/frontend/elements/photo-lightbox.html index 7e1f238..6d7ca9e 100644 --- a/frontend/elements/photo-lightbox.html +++ b/frontend/elements/photo-lightbox.html @@ -242,7 +242,7 @@ Polymer({ console.log("Download tapped"); var anchor = document.createElement('a'); - anchor.href = this.base + this.item.path + "/" + this.item.filename; + anchor.href = this.base + this.item.path + this.item.filename; anchor.setAttribute("download", this.src.replace(/.*\/([^/]+)$/, "$1")); anchor.style.display = "none"; document.body.appendChild(anchor); @@ -355,10 +355,15 @@ Polymer({ attached: function() { var base = document.querySelector("base"); if (base) { - this.base = new URL(base.href).pathname.replace(/\/$/, ""); /* Remove trailing slash if there */ + base = new URL(base.href).pathname.replace(/\/$/, ""); /* Remove trailing slash if there */ } else { - this.base = ""; + base = ""; } + /* If base is configured, add a trailing slash */ + if (base.length) { + base += "/"; + } + this.base = base; } });