url.js 251 B

12345678910
  1. export const getAbsoluteURL = function (url) {
  2. // Check if absolute URL
  3. if (!url.match(/^https?:\/\//)) {
  4. const div = document.createElement('div')
  5. div.innerHTML = `<a href="${url}">x</a>`
  6. url = div.firstChild.href
  7. }
  8. return url
  9. }