From e4052218d8ecceaad8581460414e99b54475b92f Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Sun, 28 Jun 2020 12:24:20 +0800 Subject: [PATCH] :bug: Fix: url image hash bug --- src/utils/common.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index b57877a..2c00b5d 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -7,6 +7,7 @@ import { IImgSize, IPathTransformedImgInfo } from './interfaces' +import { URL } from 'url' export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://')) export const isUrlEncode = (url: string): boolean => { @@ -82,9 +83,10 @@ export const getURLFile = async (url: string): Promise }) clearTimeout(timeoutId) if (isImage) { + const urlPath = new URL(requestOptions.url).pathname resolve({ buffer: res, - fileName: path.basename(requestOptions.url.split('?')[0]), + fileName: path.basename(urlPath), extname, success: true })