
// # 때문에 안되던거 가능함
export const getUrlParams = function (url: string) {
  var params: { [key: string]: string } = {};
  (url + '?').split('?')[1].split('&').forEach(function (pair) {
    let value = (pair + '=').split('=').map(decodeURIComponent);
    if (pair[0].length) {
      params[value[0]] = value[1];
    }
  });
  return params;
};

export const getFromUrl = (get: string): string | null => {
  const url_string = window.location.href;
  const url = new URL(url_string);
  const ln = url.searchParams.get(get);

  return ln?.replace("/", "") || null;
};

type Tresult = {
  [key: string]: string;
};

export const getAllFromUrl = (): Tresult => {
  const url_string = window.location.href;
  const url = new URL(url_string);
  let params: Tresult = {};

  url.searchParams.forEach((value, key) => {
    params[key] = value;
  });


  return params;
};

export const getFullHost = () => location.protocol + '//' + location.host + '/';
