Fix #14: Do not add a slash between path and filename

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-10-23 18:53:08 -07:00
parent 903dfb6831
commit 87ffebd737

View File

@ -242,7 +242,7 @@ Polymer({
console.log("Download tapped"); console.log("Download tapped");
var anchor = document.createElement('a'); 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.setAttribute("download", this.src.replace(/.*\/([^/]+)$/, "$1"));
anchor.style.display = "none"; anchor.style.display = "none";
document.body.appendChild(anchor); document.body.appendChild(anchor);
@ -355,10 +355,15 @@ Polymer({
attached: function() { attached: function() {
var base = document.querySelector("base"); var base = document.querySelector("base");
if (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 { } else {
this.base = ""; base = "";
} }
/* If base is configured, add a trailing slash */
if (base.length) {
base += "/";
}
this.base = base;
} }
}); });
</script> </script>