Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function extractSiteData(url, cookie) {
const normalizedGivenUrl = normalize(url, { forceHttps: true });
const parsedUrl = new URL(normalizedGivenUrl);
const siteList = await getUserSiteList(cookie);
logger.addExtraData({ userSiteList: siteList });
if (parsedUrl.hostname === editorDomain) {
const metasiteId = extractDataFromEditorUrl(parsedUrl);
const site = siteList.find(site => site.metasiteId === metasiteId);
return {
metasiteId,
siteName: site ? site.siteName : null,
siteBelongsToUser: !!site
};
} else if (
parsedUrl.hostname.endsWith(publicWixDomain) &&
parsedUrl.pathname.startsWith(editorPath)
) {
const metasiteId = extractDataFromPublicUrl(parsedUrl);
const site = siteList.find(site => site.metasiteId === metasiteId);