Skip to content

Commit

Permalink
fix(fs): support asset filenames with percent encoding
Browse files Browse the repository at this point in the history
Fix #10188
  • Loading branch information
andelf committed Sep 15, 2023
1 parent 5f4c06b commit 8f5b1da
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions resources/js/preload.js
Expand Up @@ -116,15 +116,21 @@ contextBridge.exposeInMainWorld('apis', {

const dest = path.join(repoPathRoot, to)
const assetsRoot = path.dirname(dest)

await fs.promises.mkdir(assetsRoot, { recursive: true })

from = from && decodeURIComponent(from || getFilePathFromClipboard())
from = from || getFilePathFromClipboard()

if (from) {
// console.debug('copy file: ', from, dest)
await fs.promises.copyFile(from, dest)
return path.basename(from)
try {
// console.debug('copy file: ', from, dest)
await fs.promises.copyFile(from, dest)
return path.basename(from)
} catch (e) {
from = decodeURIComponent(from)
await fs.promises.copyFile(from, dest)
return path.basename(from)
}
}

// support image
Expand Down

0 comments on commit 8f5b1da

Please sign in to comment.