Skip to content

Commit 9d236be

Browse files
author
Ozan Tellioglu
committed
Greedy Regex for WikiLinks Correction
1 parent 01b52d2 commit 9d236be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class WikiMarkdownHandler {
451451
// --> Converts links within given string from Wiki to MD
452452
static convertWikiLinksToMarkdown = (md: string): string => {
453453
let newMdText = md;
454-
let wikiRegex = /\[\[.*\]\]/g;
454+
let wikiRegex = /\[\[.*?\]\]/g;
455455
let matches = newMdText.match(wikiRegex);
456456
if (matches) {
457457
let fileRegex = /(?<=\[\[).*?(?=(\]|\|))/;
@@ -471,11 +471,11 @@ export class WikiMarkdownHandler {
471471
// --> Converts links within given string from MD to Wiki
472472
static convertMarkdownLinksToWikiLinks = (md: string): string => {
473473
let newMdText = md;
474-
let mdLinkRegex = /\[(^$|.*?)\]\((.*)\)/g;
474+
let mdLinkRegex = /\[(^$|.*?)\]\((.*?)\)/g;
475475
let matches = newMdText.match(mdLinkRegex);
476476
if (matches) {
477477
let fileRegex = /(?<=\().*(?=\))/;
478-
let altRegex = /(?<=\[)(^$|.*)(?=\])/;
478+
let altRegex = /(?<=\[)(^$|.*?)(?=\])/;
479479
for (let mdLink of matches) {
480480
let fileMatch = mdLink.match(fileRegex);
481481
if (fileMatch) {

0 commit comments

Comments
 (0)