Skip to content

Commit

Permalink
1. fix bug for image filename;
Browse files Browse the repository at this point in the history
2. support more image type.
  • Loading branch information
Doradx committed Sep 6, 2023
1 parent 09c2951 commit 8ef37dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282190,7 +282190,7 @@ const imageminSvgo = __nccwpck_require__(14038);

async function migrateNotionImageFromURL(ctx, url) {
// 检查图片是否为notion的图片
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|png|gif|webp)\?.+/;
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|bmp|tif|tiff|svg|png|gif|webp)\?.+/;
if (!urlReg.test(url)) {
console.log(`Image ${url} is not a notion image, skip`);
return url;
Expand All @@ -282213,11 +282213,11 @@ async function migrateNotionImageFromURL(ctx, url) {
// 从URL获取图片信息
let imageItem = await handlePicFromURL(ctx, url);
// 检查是否需要压缩图片
if (ctx.getConfig('compress')) {
if (ctx.getConfig('compress') && ext!=='svg') {
// 压缩图片
imageItem = await compressPic(imageItem);
}
imageItem.fileName = `${uuid}${ext}`;
imageItem.fileName = `${uuid}.${ext}`;
// 上传图片
const result = await ctx.upload([imageItem]);
if (result && result[0] && result[0].imgUrl) {
Expand Down
6 changes: 3 additions & 3 deletions src/migrateNotionImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const imageminSvgo = require("imagemin-svgo");

async function migrateNotionImageFromURL(ctx, url) {
// 检查图片是否为notion的图片
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|png|gif|webp)\?.+/;
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|bmp|tif|tiff|svg|png|gif|webp)\?.+/;
if (!urlReg.test(url)) {
console.log(`Image ${url} is not a notion image, skip`);
return url;
Expand All @@ -46,11 +46,11 @@ async function migrateNotionImageFromURL(ctx, url) {
// 从URL获取图片信息
let imageItem = await handlePicFromURL(ctx, url);
// 检查是否需要压缩图片
if (ctx.getConfig('compress')) {
if (ctx.getConfig('compress') && ext!=='svg') {
// 压缩图片
imageItem = await compressPic(imageItem);
}
imageItem.fileName = `${uuid}${ext}`;
imageItem.fileName = `${uuid}.${ext}`;
// 上传图片
const result = await ctx.upload([imageItem]);
if (result && result[0] && result[0].imgUrl) {
Expand Down

0 comments on commit 8ef37dc

Please sign in to comment.