Fix hash == ""
This commit is contained in:
@@ -63,6 +63,10 @@ export async function getRedactedCurrentLocation(origin: string, hash: string, p
|
|||||||
pathname = "/<redacted_file_scheme_url>/";
|
pathname = "/<redacted_file_scheme_url>/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hashStr;
|
||||||
|
if (hash == "") {
|
||||||
|
hashStr = "";
|
||||||
|
} else {
|
||||||
let [_, screen, ...parts] = hash.split("/");
|
let [_, screen, ...parts] = hash.split("/");
|
||||||
|
|
||||||
if (!knownScreens.has(screen)) {
|
if (!knownScreens.has(screen)) {
|
||||||
@@ -73,7 +77,8 @@ export async function getRedactedCurrentLocation(origin: string, hash: string, p
|
|||||||
parts[i] = anonymity === Anonymity.Anonymous ? `<redacted>` : await hashHex(parts[i]);
|
parts[i] = anonymity === Anonymity.Anonymous ? `<redacted>` : await hashHex(parts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hashStr = `${_}/${screen}/${parts.join("/")}`;
|
hashStr = `${_}/${screen}/${parts.join("/")}`;
|
||||||
|
}
|
||||||
return origin + pathname + hashStr;
|
return origin + pathname + hashStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,12 @@ bd75b3e080945674c0351f75e0db33d1e90986fa07b318ea7edf776f5eef38d4`);
|
|||||||
expect(location).toBe("https://foo.bar/#/<redacted_screen_name>/<redacted>/<redacted>");
|
expect(location).toBe("https://foo.bar/#/<redacted_screen_name>/<redacted>/<redacted>");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should currently handle an empty hash", async () => {
|
||||||
|
const location = await getRedactedCurrentLocation(
|
||||||
|
"https://foo.bar", "", "/", Anonymity.Anonymous);
|
||||||
|
expect(location).toBe("https://foo.bar/");
|
||||||
|
});
|
||||||
|
|
||||||
it("Should identify the user to posthog if pseudonymous", async () => {
|
it("Should identify the user to posthog if pseudonymous", async () => {
|
||||||
analytics.init(Anonymity.Pseudonymous);
|
analytics.init(Anonymity.Pseudonymous);
|
||||||
await analytics.identifyUser("foo");
|
await analytics.identifyUser("foo");
|
||||||
|
|||||||
Reference in New Issue
Block a user