export function previewFormat(path) {
  let previewPath = path;
  if (previewPath && previewPath !== '/' && path.charAt(0) === '/') {
    previewPath = path.substring(1);
  }

  return previewPath;
}

export function previewPath(path) {
  // eslint-disable-next-line no-restricted-globals
  const searchParams2 = typeof window !== 'undefined' ? new URLSearchParams(location.search) : null;
  return `/preview?path=${previewFormat(path)}&market_id=${searchParams2.get('market_id')}`;
}

export function formatPath(path) {
  let link = path;
  if (path.charAt(0) !== '/') {
    link = `/${path}`;
  }

  return link;
}
