Answers for "How to join all url segments to make a url in javascipt 30seconds of code"

0

How to join all url segments to make a url in javascipt 30seconds of code

const URLJoin = (...args) =>
  args
    .join('/')
    .replace(/[\/]+/g, '/')
    .replace(/^(.+):\//, '$1://')
    .replace(/^file:/, 'file:/')
    .replace(/\/(\?|&|#[^!])/g, '$1')
    .replace(/\?/g, '&')
    .replace('&', '?');
Posted by: Guest on March-29-2021

Code answers related to "How to join all url segments to make a url in javascipt 30seconds of code"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language