From c81bc7d5cd61e4f393bf44f7c298a3b2e972fe14 Mon Sep 17 00:00:00 2001 From: Zachatoo Date: Tue, 3 Sep 2024 20:17:04 -0600 Subject: [PATCH] fix: Include link to photographer in random image refs: #1435 --- .../internal_functions/web/InternalModuleWeb.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/functions/internal_functions/web/InternalModuleWeb.ts b/src/core/functions/internal_functions/web/InternalModuleWeb.ts index eb2f5c36..ad97b51b 100644 --- a/src/core/functions/internal_functions/web/InternalModuleWeb.ts +++ b/src/core/functions/internal_functions/web/InternalModuleWeb.ts @@ -12,7 +12,6 @@ export class InternalModuleWeb extends InternalModule { "random_picture", this.generate_random_picture() ); - } async create_dynamic_templates(): Promise {} @@ -73,9 +72,9 @@ export class InternalModuleWeb extends InternalModule { } } if (include_size) { - return `![photo by ${response.photog} on Unsplash|${size}](${url})`; + return `![photo by ${response.photog}(${response.photogUrl}) on Unsplash|${size}](${url})`; } - return `![photo by ${response.photog} on Unsplash](${url})`; + return `![photo by ${response.photog}(${response.photogUrl}) on Unsplash](${url})`; } catch (error) { new TemplaterError("Error generating random picture"); return "Error generating random picture"; @@ -83,21 +82,20 @@ export class InternalModuleWeb extends InternalModule { }; } - generate_request(): ( - url: string, - path?: string, - ) => Promise { + generate_request(): (url: string, path?: string) => Promise { return async (url: string, path?: string) => { try { const response = await this.getRequest(url); const jsonData = await response.json(); if (path && jsonData) { - return path.split('.').reduce((obj, key) => { + return path.split(".").reduce((obj, key) => { if (obj && obj.hasOwnProperty(key)) { return obj[key]; } else { - throw new Error(`Path ${path} not found in the JSON response`); + throw new Error( + `Path ${path} not found in the JSON response` + ); } }, jsonData); }