Skip to content

Commit

Permalink
fix: url with space, angle brackets and parentheses is no longer brok…
Browse files Browse the repository at this point in the history
…en in markdown

fix #16
  • Loading branch information
aidenlx committed Apr 24, 2021
1 parent 2f5a47b commit f9f678c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,19 @@ function getReplaceText(
}
}

/** Process file url etc */
/** Process file url, special characters, etc */
function processUrl(src: string): string {
let output;
if (testFilePath(src)){
return fileUrl(src, { resolve: false });
output = fileUrl(src, { resolve: false });
} else {
return src;
output = src;
}

if (/[<>]/.test(output))
output = output.replace("<", "%3C").replace(">", "%3E");

return /[\(\) ]/.test(output) ? `<${output}>` : output;
}

function getCbText(cb: string | ClipboardEvent): string | null {
Expand Down

0 comments on commit f9f678c

Please sign in to comment.