chasem.co

Get URLs from the src attribute of an HTML image tag

const srcRegex = /<img.*?src=['"](.*?)['"]/
const src = srcRegex.exec(string)[1]

// string = "<img src='http://link-to-image.com/image.png' />"
// src = "http://link-to-image.com/image.png"

Test whether a URL is internal or not

const internal = /^\/(?!\/)/.test(url)

Strip HTML tags out of a string

const stripHTML = (string) => string.replace(/<[^>]+>/g, '')