// eslint-disable-next-line import/prefer-default-export
const getRecommendedToplist = (marketSections) => {
  if (marketSections.recommended_casinos && marketSections.recommended_casinos.modules) {
    if (
      marketSections.recommended_casinos.modules.length > 0 &&
      marketSections.recommended_casinos.modules[0].items.length > 0
    ) {
      return marketSections.recommended_casinos.modules[0].items[0].items;
    }
  }

  return null;
};

const getDomain = (url) => {
  const matches = url.split('/');
  return matches.length >= 2 ? `${matches[0]}//${matches[2]}` : url;
};

module.exports = { getDomain, getRecommendedToplist };
