chore: Remove DEPLOYMENT and SUBDOMAINS_ENABLED (#5742)

This commit is contained in:
Tom Moor
2023-08-28 20:39:58 -04:00
committed by GitHub
parent 7725f29dc7
commit 30a4303a8e
35 changed files with 136 additions and 135 deletions

View File

@@ -169,27 +169,27 @@ describe("#slugifyDomain", () => {
describe("#getCookieDomain", () => {
beforeEach(() => {
env.URL = "https://example.com";
env.SUBDOMAINS_ENABLED = true;
});
it("returns the normalized app host when on the host domain", () => {
expect(getCookieDomain("subdomain.example.com")).toBe("example.com");
expect(getCookieDomain("www.example.com")).toBe("example.com");
expect(getCookieDomain("http://example.com:3000")).toBe("example.com");
expect(getCookieDomain("myteam.example.com/document/12345?q=query")).toBe(
expect(getCookieDomain("subdomain.example.com", true)).toBe("example.com");
expect(getCookieDomain("www.example.com", true)).toBe("example.com");
expect(getCookieDomain("http://example.com:3000", true)).toBe(
"example.com"
);
expect(
getCookieDomain("myteam.example.com/document/12345?q=query", true)
).toBe("example.com");
});
it("returns the input if not on the host domain", () => {
expect(getCookieDomain("www.blogspot.com")).toBe("www.blogspot.com");
expect(getCookieDomain("anything else")).toBe("anything else");
expect(getCookieDomain("www.blogspot.com", true)).toBe("www.blogspot.com");
expect(getCookieDomain("anything else", true)).toBe("anything else");
});
it("always returns the input when subdomains are not enabled", () => {
env.SUBDOMAINS_ENABLED = false;
expect(getCookieDomain("example.com")).toBe("example.com");
expect(getCookieDomain("www.blogspot.com")).toBe("www.blogspot.com");
expect(getCookieDomain("anything else")).toBe("anything else");
it("always returns the input when not cloud hosted", () => {
expect(getCookieDomain("example.com", false)).toBe("example.com");
expect(getCookieDomain("www.blogspot.com", false)).toBe("www.blogspot.com");
expect(getCookieDomain("anything else", false)).toBe("anything else");
});
});

View File

@@ -65,10 +65,10 @@ export function parseDomain(url: string): Domain {
};
}
export function getCookieDomain(domain: string) {
export function getCookieDomain(domain: string, isCloudHosted: boolean) {
// always use the base URL for cookies when in hosted mode
// and the domain is not custom
if (env.SUBDOMAINS_ENABLED) {
if (isCloudHosted) {
const parsed = parseDomain(domain);
if (!parsed.custom) {