const { URL } = require('url');

module.exports = (url, queryObject = {}) => {
    let urlObject = url instanceof URL ? url : new URL(url);

    for (let [key, value] of Object.entries(queryObject)) {
        urlObject.searchParams.set(key, value);
    }

    return urlObject;
};
