Node.js scraping, converting image src -> full URL
javascript, jsdom, node.js, path
Solution
Look at the node `url` module. Specifically `url.resolve(from, to)` should be what you're looking for.
Problem
I'm using Cheerio (https://github.com/MatthewMueller/cheerio) to scrape websites and get images for a project I'm working on. I'm wondering if there's an easy way with Node.js (or another package) to convert the $(img).attr('src') to a fully qualified URL? Sometimes I'll get "image.jpg" and other times "../../image.jpg", and other times "//somepath/image.jpg". Perhaps I'm just missing a regex of some sort... Thanks for your time :)