mirror of
https://github.com/outline/outline.git
synced 2026-12-06 03:05:08 +03:00
* fix: Correct logic errors in shared utilities * fix: Restore per-column cells in getCellsInRow and convert every attachment url The g flag made the attachment regex skip every second match, and removing duplicate cells broke callers that index getCellsInRow by column. * test: Cover uppercase attachment URLs * revert: Remove uncertain fixes
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import sharedEnv from "../env";
|
|
import parseCollectionSlug from "./parseCollectionSlug";
|
|
|
|
sharedEnv.URL = "https://app.outline.dev";
|
|
|
|
describe("#parseCollectionSlug", () => {
|
|
it("should work with fully qualified url", () => {
|
|
expect(
|
|
parseCollectionSlug("http://example.com/collection/test-ANzZwgv2RG")
|
|
).toEqual("test-ANzZwgv2RG");
|
|
});
|
|
|
|
it("should work with paths after document slug", () => {
|
|
expect(
|
|
parseCollectionSlug(
|
|
"http://mywiki.getoutline.com/collection/test-ANzZwgv2RG/recent"
|
|
)
|
|
).toEqual("test-ANzZwgv2RG");
|
|
});
|
|
|
|
it("should work with hash", () => {
|
|
expect(
|
|
parseCollectionSlug(
|
|
"http://mywiki.getoutline.com/collection/test-ANzZwgv2RG#state"
|
|
)
|
|
).toEqual("test-ANzZwgv2RG");
|
|
});
|
|
|
|
it("should work with subdomain qualified url", () => {
|
|
expect(
|
|
parseCollectionSlug(
|
|
"http://mywiki.getoutline.com/collection/test-ANzZwgv2RG"
|
|
)
|
|
).toEqual("test-ANzZwgv2RG");
|
|
});
|
|
|
|
it("should work with path", () => {
|
|
expect(parseCollectionSlug("/collection/test-ANzZwgv2RG")).toEqual(
|
|
"test-ANzZwgv2RG"
|
|
);
|
|
});
|
|
|
|
it("should work with path and hash", () => {
|
|
expect(parseCollectionSlug("/collection/test-ANzZwgv2RG#somehash")).toEqual(
|
|
"test-ANzZwgv2RG"
|
|
);
|
|
});
|
|
|
|
it("should return undefined when the collection segment is missing", () => {
|
|
expect(parseCollectionSlug("https://example.com/about")).toBeUndefined();
|
|
expect(parseCollectionSlug("/collection/")).toBeUndefined();
|
|
});
|
|
});
|