Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getWpUrl = (api: string, isWpCom: boolean): URL => {
const apiUrl = new URL(api);
if (isWpCom) {
const { pathname } = apiUrl;
return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
}
// Get API subdirectory.
const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
return new URL(apiSubdir, apiUrl);
};
const getWpUrl = (api: string, isWpCom: boolean): URL => {
const apiUrl = new URL(api);
if (isWpCom) {
const { pathname } = apiUrl;
return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
}
// Get API subdirectory.
const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
return new URL(apiSubdir, apiUrl);
};
const getWpUrl = (api: string, isWpCom: boolean): URL => {
const apiUrl = new URL(api);
if (isWpCom) {
const { pathname } = apiUrl;
return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
}
// Get API subdirectory.
const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
return new URL(apiSubdir, apiUrl);
};
const getNewLink = (value: string, base: string, newBase: string) => {
const { pathname, search, hash } = new URL(value);
const finalPathname = pathname.replace(
new RegExp(`^${new URL(base).pathname}`),
"/"
);
return `${newBase.replace(/\/?$/, "")}${finalPathname}${search}${hash}`;
};
const getNewLink = (value: string, base: string, newBase: string) => {
const { pathname, search, hash } = new URL(value);
const finalPathname = pathname.replace(
new RegExp(`^${new URL(base).pathname}`),
"/"
);
return `${newBase.replace(/\/?$/, "")}${finalPathname}${search}${hash}`;
};
const Root = connect(({ state }) => {
const { pathname } = new URL(state.router.link, "http://localhost:3001");
if (pathname === "/background-blue") return ;
if (pathname === "/color-red") return ;
if (pathname === "/styled-css") return ;
});