Skip to content

Commit e405221

Browse files
committed
🐛 Fix: url image hash bug
1 parent 379db06 commit e405221

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/utils/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
IImgSize,
88
IPathTransformedImgInfo
99
} from './interfaces'
10+
import { URL } from 'url'
1011

1112
export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://'))
1213
export const isUrlEncode = (url: string): boolean => {
@@ -82,9 +83,10 @@ export const getURLFile = async (url: string): Promise<IPathTransformedImgInfo>
8283
})
8384
clearTimeout(timeoutId)
8485
if (isImage) {
86+
const urlPath = new URL(requestOptions.url).pathname
8587
resolve({
8688
buffer: res,
87-
fileName: path.basename(requestOptions.url.split('?')[0]),
89+
fileName: path.basename(urlPath),
8890
extname,
8991
success: true
9092
})

0 commit comments

Comments
 (0)