Common:Utils: update setCookie: disable encoding with flag
This commit is contained in:
parent
8dbfda6f2b
commit
5d30cdca13
@ -205,14 +205,14 @@ export function getCookie(name) {
|
||||
let matches = document.cookie.match(
|
||||
new RegExp(
|
||||
"(?:^|; )" +
|
||||
name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
|
||||
"=([^;]*)"
|
||||
name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
|
||||
"=([^;]*)"
|
||||
)
|
||||
);
|
||||
return matches ? decodeURIComponent(matches[1]) : undefined;
|
||||
}
|
||||
|
||||
export function setCookie(name, value, options = {}) {
|
||||
export function setCookie(name, value, options = {}, disableEncoding = false) {
|
||||
options = {
|
||||
path: "/",
|
||||
...options,
|
||||
@ -222,8 +222,9 @@ export function setCookie(name, value, options = {}) {
|
||||
options.expires = options.expires.toUTCString();
|
||||
}
|
||||
|
||||
let updatedCookie =
|
||||
encodeURIComponent(name) + "=" + encodeURIComponent(value);
|
||||
let updatedCookie = disableEncoding
|
||||
? encodeURIComponent(name) + "=" + value
|
||||
: encodeURIComponent(name) + "=" + encodeURIComponent(value);
|
||||
|
||||
for (let optionKey in options) {
|
||||
updatedCookie += "; " + optionKey;
|
||||
@ -275,7 +276,12 @@ export function toCommunityHostname(hostname) {
|
||||
return communityHostname;
|
||||
}
|
||||
|
||||
export function getProviderTranslation(provider, t, linked = false, signUp = false) {
|
||||
export function getProviderTranslation(
|
||||
provider,
|
||||
t,
|
||||
linked = false,
|
||||
signUp = false
|
||||
) {
|
||||
const capitalizeProvider =
|
||||
provider.charAt(0).toUpperCase() + provider.slice(1);
|
||||
if (linked) {
|
||||
@ -286,15 +292,25 @@ export function getProviderTranslation(provider, t, linked = false, signUp = fal
|
||||
case "apple":
|
||||
return signUp ? t("Common:SignUpWithApple") : t("Common:SignInWithApple");
|
||||
case "google":
|
||||
return signUp ? t("Common:SignUpWithGoogle") : t("Common:SignInWithGoogle");
|
||||
return signUp
|
||||
? t("Common:SignUpWithGoogle")
|
||||
: t("Common:SignInWithGoogle");
|
||||
case "facebook":
|
||||
return signUp ? t("Common:SignUpWithFacebook") : t("Common:SignInWithFacebook");
|
||||
return signUp
|
||||
? t("Common:SignUpWithFacebook")
|
||||
: t("Common:SignInWithFacebook");
|
||||
case "twitter":
|
||||
return signUp ? t("Common:SignUpWithTwitter") : t("Common:SignInWithTwitter");
|
||||
return signUp
|
||||
? t("Common:SignUpWithTwitter")
|
||||
: t("Common:SignInWithTwitter");
|
||||
case "linkedin":
|
||||
return signUp ? t("Common:SignUpWithLinkedIn") : t("Common:SignInWithLinkedIn");
|
||||
return signUp
|
||||
? t("Common:SignUpWithLinkedIn")
|
||||
: t("Common:SignInWithLinkedIn");
|
||||
case "microsoft":
|
||||
return signUp ? t("Common:SignUpWithMicrosoft") : t("Common:SignInWithMicrosoft");
|
||||
return signUp
|
||||
? t("Common:SignUpWithMicrosoft")
|
||||
: t("Common:SignInWithMicrosoft");
|
||||
case "sso":
|
||||
return signUp ? t("Common:SignUpWithSso") : t("Common:SignInWithSso");
|
||||
case "zoom":
|
||||
@ -411,7 +427,7 @@ export function isElementInViewport(el) {
|
||||
rect.top >= 0 &&
|
||||
rect.left >= 0 &&
|
||||
rect.bottom <=
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
||||
);
|
||||
}
|
||||
@ -621,6 +637,6 @@ export const getSystemTheme = () => {
|
||||
: ThemeKeys.BaseStr
|
||||
: window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? ThemeKeys.DarkStr
|
||||
: ThemeKeys.BaseStr;
|
||||
? ThemeKeys.DarkStr
|
||||
: ThemeKeys.BaseStr;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user