简体   繁体   中英

How to safely convert text to html code in a way that makes links clickable?

Example input:

Hello. Please go to example.com! <script>/*this should not be executed*/</script>

Example output:

Hello: Please go to <a href="http.//example.com">example.com</a>! &ltscript&gt/*this should not be executed*/&lt/script&gt

I am using Javascript. If this is already answered, please give me a link.

Apparently, https://linkify.js.org/ works the way I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM