diff --git a/CHANGELOG.md b/CHANGELOG.md index 6448838..17519b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ # Change Log - ## 0.19.1 (May 28, 2022) - Fixed paste as base64 not work on Windows. #86 diff --git a/src/paster.ts b/src/paster.ts index 57c58eb..94c4625 100644 --- a/src/paster.ts +++ b/src/paster.ts @@ -4,7 +4,6 @@ import { spawn } from "child_process"; import * as moment from "moment"; import * as vscode from "vscode"; import { toMarkdown } from "./toMarkdown"; -import * as fs from "fs"; import { prepareDirForFile, @@ -272,7 +271,8 @@ class Paster { let inputUri = vscode.Uri.parse(inputVal); - if (fs.lstatSync(inputUri.fsPath).isDirectory()) { + const last_char = inputUri.fsPath.slice(inputUri.fsPath.length - 1); + if (["/", "\\"].includes(last_char)) { // While filename is empty(ex: /abc/?200,20), paste clipboard to a temporay file, then convert it to base64 image to markdown. pasteImgContext.targetFile = newTemporaryFilename(); pasteImgContext.convertToBase64 = true; diff --git a/test/suite/extension.test.ts b/test/suite/extension.test.ts index 371d7d7..f045c27 100644 --- a/test/suite/extension.test.ts +++ b/test/suite/extension.test.ts @@ -61,5 +61,10 @@ suite("Extension Tests", () => { paster.Paster.encodePath(targetFile.fsPath), "w:/Source%20Markdown/Build%20Ours%20Blog/images/test.gif" ); + + ret = paster.Paster.parsePasteImageContext( + "d:/Source Markdown/Build Ours Blog/images/" + ); + assert.strictEqual(ret.convertToBase64, true); }); });