Skip to content

Commit

Permalink
optimize: getFileExtension function
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Oct 11, 2024
1 parent ba47798 commit c6c14bc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export function getFileExtension(url: string) {
// 移除查询参数
const pathWithoutQuery = origin.split('?')[0];

const lastDotIndex = pathWithoutQuery.lastIndexOf('.');
if (lastDotIndex === -1) return '';
const ext = pathWithoutQuery.match(/\.([^.\/\\]+)$/);

return pathWithoutQuery.substring(lastDotIndex + 1);
return ext?.[1];
}

export function resolveProtocol() {
Expand Down

0 comments on commit c6c14bc

Please sign in to comment.