Skip to content

Commit

Permalink
add an new test case for parsePasteImageContext
Browse files Browse the repository at this point in the history
  • Loading branch information
telesoho committed May 27, 2022
1 parent b24d224 commit 2585ad1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Change Log


## 0.19.1 (May 28, 2022)

- Fixed paste as base64 not work on Windows. #86
Expand Down
4 changes: 2 additions & 2 deletions src/paster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 2585ad1

Please sign in to comment.