Skip to content

Commit

Permalink
update url parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ianjennings committed Feb 25, 2024
1 parent 76552f5 commit c99f7b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ const UZip = require("uzip");
const colors = require("colors");

function extractLink(markdownString) {
const regex = /\[.*?\]\((.*?)\)/g;
const urls = [];
let match;

while ((match = regex.exec(markdownString)) !== null) {
urls.push(match[1]);
}

return urls;
const regex = /\[!\[.*?\]\(.*?\)\]\((.*?)\)/;
const match = markdown.match(regex);
return match[1];
}

const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));
Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const markdown = `[![slack - Slack - standups - Dashcam](https://replayable-api-production.herokuapp.com/replay/65d5543860e6e600640d2757/gif?shareKey=UQqPY2VywrcFPLZXSRsWaA)](https://app.dashcam.io/replay/65d5543860e6e600640d2757?share=UQqPY2VywrcFPLZXSRsWaA)`;

const regex = /\[!\[.*?\]\(.*?\)\]\((.*?)\)/;
const match = markdown.match(regex);

if (match) {
console.log(match);
console.log(match[1]); // This will log the URL you're looking for
} else {
console.log("No URL found");
}

0 comments on commit c99f7b7

Please sign in to comment.