From 8bea114b76f3843c316c5aea2171c662431a4f91 Mon Sep 17 00:00:00 2001 From: Jelle De Loecker Date: Fri, 27 Dec 2024 12:45:31 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`Alchemy#download(path)`?= =?UTF-8?q?=20breaking=20when=20no=20name=20is=20found=20to=20store=20file?= =?UTF-8?q?=20as?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + lib/core/alchemy_functions.js | 8 ++++++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be22757..860abac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Fix `Conduit#parseRequest()` forgetting GET query parameters when overriding respone url * Make `Model#aggregate(pipeline)` work again +* Fix `Alchemy#download(path)` breaking when no name is found to store file as ## 1.4.0-alpha.8 (2024-11-28) diff --git a/lib/core/alchemy_functions.js b/lib/core/alchemy_functions.js index b3b3b6e..b80ef14 100644 --- a/lib/core/alchemy_functions.js +++ b/lib/core/alchemy_functions.js @@ -1159,7 +1159,7 @@ function convertDataUriToFile(data_uri) { * * @author Jelle De Loecker * @since 1.3.0 - * @version 1.3.0 + * @version 1.4.0 * * @param {string} url * @@ -1226,10 +1226,14 @@ Alchemy.setMethod(function download(url, options) { } if (!name) { - name = alchemy.ObjectId(); + name = alchemy.ObjectId() + ''; } } + if (!name || typeof name != 'string') { + name = alchemy.ObjectId() + ''; + } + if (name.indexOf('/') > -1) { name = name.replaceAll('/', '-'); } diff --git a/package.json b/package.json index 23a245f..d4e9911 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alchemymvc", "description": "MVC framework for Node.js", - "version": "1.4.0-alpha.8", + "version": "1.4.0-alpha.9", "author": "Jelle De Loecker ", "keywords": [ "alchemy",