~james/core

core/web/src/lib/handle.test.ts -rw-r--r-- 702 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { describe, expect, it } from "vitest";
import { normalizeHandle } from "#lib/handle.ts";

describe("normalizeHandle", () => {
	it("strips the bidi marks a handle copied from bsky.app carries", () => {
		expect(normalizeHandle("\u202a@nelind.dk\u202c")).toBe("nelind.dk");
	});

	it("strips a right-to-left override anywhere in the handle", () => {
		expect(normalizeHandle("evil\u202egro.delgnat")).toBe("evilgro.delgnat");
	});

	it("trims, drops a leading @ and lowercases", () => {
		expect(normalizeHandle("  @Alice.Tngl.SH ")).toBe("alice.tngl.sh");
	});

	it("keeps a did's case", () => {
		expect(normalizeHandle("\u202adid:web:Example.com\u202c")).toBe("did:web:Example.com");
	});
});