1/** 2 * for lazy people who don't want to type out `new URL('http://blah' + req.url).searchParams.get(ugh)` all the time 3 */ 4module.exports = class URLPath extends URL { 5 /** 6 * @param {string} path - /site/path 7 */ 8 constructor(path) { 9 super(path, 'http://foobar'); 10 } 11 /** 12 * @param {string} param - ?param=value 13 * @returns {string|null} 14 */ 15 get(param) { 16 return this.searchParams.get(param); 17 } 18 /** 19 * @returns {{[param: string]: string}} 20 */ 21 getParams() { 22 return Object.fromEntries(this.searchParams); 23 } 24}; 25 26