You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Output- Fruit
- Apple
- Orange
- Banana
- Dairy
- Milk
- Cheese
I created my own version of oembed transformer that included a fallback, that if the extracted link is not an oembed link, then I use my own custom bookmark around it.
What happened:
Unfortunately @remark-emedder/core returns even simple strings as URLs:
Problem description:
@remark-emedder/core getUrlString returns every single line string as url (with https:// appended to it. It seems to later rely on shouldTransform function to filter all such links out, but in some cases this is too late. I can't check in shouldTransform function if the link is a valid URL, because it always is, coming out of getUrlString function.
Suggested solution:
Enhance the getUrlString function to check if the given text is actually a link using some robust regex, and only return a true, viable URL
Something like this works:
constgetUrlString=url=>{consturlRegex=newRegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);if(!urlRegex.test(url)){console.log('🚩 Not a valid URL!:',url);returnnull;}consturlString=url.startsWith('http') ? url : `https://${url}`;try{returnnewURL(urlString).toString();}catch(error){returnnull;}};
The text was updated successfully, but these errors were encountered:
remark-embedder-core
version: 3.0.3node
version: v20.10.0npm
version: 10.2.3Relevant code or config
What you did: I run a simple markdown like below:
I created my own version of oembed transformer that included a fallback, that if the extracted link is not an oembed link, then I use my own custom bookmark around it.
What happened:
Unfortunately @remark-emedder/core returns even simple strings as URLs:
Reproduction repository:
Problem description:
@remark-emedder/core
getUrlString
returns every single line string as url (withhttps://
appended to it. It seems to later rely onshouldTransform
function to filter all such links out, but in some cases this is too late. I can't check inshouldTransform
function if the link is a valid URL, because it always is, coming out ofgetUrlString
function.Suggested solution:
Enhance the
getUrlString
function to check if the given text is actually a link using some robust regex, and only return a true, viable URLSomething like this works:
The text was updated successfully, but these errors were encountered: