I need your help and I'm a little bit lost. So I want to obtain "https://cloud.send.cm/i/00344/zofwynu8cxc7.jpg" from "https://send.cm/zofwynu8cxc7.html" . As you can see "zofwynu8cxc7" is the same in both links, so basically I need to copy this photo's id to the other link. This should be possibly using regexp in js, but I'm not quite sure how. Thank you
CodePudding user response:
Here's the new URL("")
code:
not sure if path.slice()
can be done with URL()
let url = new URL("https://send.cm/zofwynu8cxc7.html")
let path = url.pathname // /zofwynu8cxc7.html
path = path.slice(0, path.length - 5) // /zofwynu8cxc7
console.log("https://cloud.send.cm/i/00344" path ".jpg")