@bash-app/bash-common 30.469.0 → 30.472.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/membershipDefinitions.test.js +4 -0
- package/dist/__tests__/membershipDefinitions.test.js.map +1 -1
- package/dist/__tests__/partnerBookingAgreement.test.js +7 -0
- package/dist/__tests__/partnerBookingAgreement.test.js.map +1 -1
- package/dist/__tests__/sideQuestWindow.test.d.ts +2 -0
- package/dist/__tests__/sideQuestWindow.test.d.ts.map +1 -0
- package/dist/__tests__/sideQuestWindow.test.js +28 -0
- package/dist/__tests__/sideQuestWindow.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/intros/__tests__/revealClock.test.d.ts +2 -0
- package/dist/intros/__tests__/revealClock.test.d.ts.map +1 -0
- package/dist/intros/__tests__/revealClock.test.js +15 -0
- package/dist/intros/__tests__/revealClock.test.js.map +1 -0
- package/dist/intros/index.d.ts +1 -0
- package/dist/intros/index.d.ts.map +1 -1
- package/dist/intros/index.js +1 -0
- package/dist/intros/index.js.map +1 -1
- package/dist/intros/revealClock.d.ts +6 -0
- package/dist/intros/revealClock.d.ts.map +1 -0
- package/dist/intros/revealClock.js +22 -0
- package/dist/intros/revealClock.js.map +1 -0
- package/dist/membershipDefinitions.d.ts.map +1 -1
- package/dist/membershipDefinitions.js +9 -2
- package/dist/membershipDefinitions.js.map +1 -1
- package/dist/partnerBookingAgreement.js +1 -1
- package/dist/partnerBookingAgreement.js.map +1 -1
- package/dist/sideQuestTypes.d.ts +4 -0
- package/dist/sideQuestTypes.d.ts.map +1 -1
- package/dist/sideQuestTypes.js.map +1 -1
- package/dist/sideQuestWindow.d.ts +22 -0
- package/dist/sideQuestWindow.d.ts.map +1 -0
- package/dist/sideQuestWindow.js +57 -0
- package/dist/sideQuestWindow.js.map +1 -0
- package/dist/utils/__tests__/plainListingHeadline.test.d.ts +2 -0
- package/dist/utils/__tests__/plainListingHeadline.test.d.ts.map +1 -0
- package/dist/utils/__tests__/plainListingHeadline.test.js +14 -0
- package/dist/utils/__tests__/plainListingHeadline.test.js.map +1 -0
- package/dist/utils/__tests__/webLinkValidation.test.js +1 -1
- package/dist/utils/__tests__/webLinkValidation.test.js.map +1 -1
- package/dist/utils/plainListingHeadline.d.ts +5 -0
- package/dist/utils/plainListingHeadline.d.ts.map +1 -0
- package/dist/utils/plainListingHeadline.js +20 -0
- package/dist/utils/plainListingHeadline.js.map +1 -0
- package/dist/utils/webLinkValidation.d.ts.map +1 -1
- package/dist/utils/webLinkValidation.js +7 -1
- package/dist/utils/webLinkValidation.js.map +1 -1
- package/package.json +1 -1
- package/prisma/schema.prisma +21 -5
- package/src/__tests__/membershipDefinitions.test.ts +5 -0
- package/src/__tests__/partnerBookingAgreement.test.ts +8 -0
- package/src/__tests__/sideQuestWindow.test.ts +42 -0
- package/src/index.ts +2 -0
- package/src/intros/__tests__/revealClock.test.ts +18 -0
- package/src/intros/index.ts +1 -0
- package/src/intros/revealClock.ts +24 -0
- package/src/membershipDefinitions.ts +6 -2
- package/src/partnerBookingAgreement.ts +1 -1
- package/src/sideQuestTypes.ts +5 -0
- package/src/sideQuestWindow.ts +80 -0
- package/src/utils/__tests__/plainListingHeadline.test.ts +19 -0
- package/src/utils/__tests__/webLinkValidation.test.ts +1 -1
- package/src/utils/plainListingHeadline.ts +22 -0
- package/src/utils/webLinkValidation.ts +10 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BashStatus } from "@prisma/client";
|
|
2
|
+
/** Unpublished, rejected, or cancelled bashes never award quest completions. */
|
|
3
|
+
export declare function bashAcceptsSideQuestCompletions(status: BashStatus | null | undefined): boolean;
|
|
4
|
+
type Window = {
|
|
5
|
+
startsAt?: Date | null;
|
|
6
|
+
endsAt?: Date | null;
|
|
7
|
+
};
|
|
8
|
+
export type SideQuestEventWindow = {
|
|
9
|
+
startDateTime?: Date | string | null;
|
|
10
|
+
endDateTime?: Date | string | null;
|
|
11
|
+
timezone?: string | null;
|
|
12
|
+
city?: string | null;
|
|
13
|
+
state?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** Unscheduled quests run from the event start through the end of that local night. Explicit quest windows override. */
|
|
17
|
+
export declare function sideQuestWindow(quest: Window, event?: SideQuestEventWindow | null): {
|
|
18
|
+
startsAt: Date | null;
|
|
19
|
+
endsAt: Date | null;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=sideQuestWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sideQuestWindow.d.ts","sourceRoot":"","sources":["../src/sideQuestWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAc5C,gFAAgF;AAChF,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GACpC,OAAO,CAET;AAED,KAAK,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AA+BF,wHAAwH;AACxH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,oBAAoB,GAAG,IAAI;;;EAepC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BashStatus } from "@prisma/client";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { resolveEventTimezoneIanaForDisplay } from "./utils/eventTimezoneIana.js";
|
|
4
|
+
const BASH_STATUSES_CLOSED_TO_QUESTS = new Set([
|
|
5
|
+
BashStatus.Idea,
|
|
6
|
+
BashStatus.Draft,
|
|
7
|
+
BashStatus.Pending,
|
|
8
|
+
BashStatus.Rejected,
|
|
9
|
+
BashStatus.Cancelled,
|
|
10
|
+
BashStatus.Archived,
|
|
11
|
+
]);
|
|
12
|
+
/** Unpublished, rejected, or cancelled bashes never award quest completions. */
|
|
13
|
+
export function bashAcceptsSideQuestCompletions(status) {
|
|
14
|
+
return status == null || !BASH_STATUSES_CLOSED_TO_QUESTS.has(status);
|
|
15
|
+
}
|
|
16
|
+
function asDate(value) {
|
|
17
|
+
if (value == null)
|
|
18
|
+
return null;
|
|
19
|
+
if (value instanceof Date)
|
|
20
|
+
return value;
|
|
21
|
+
const parsed = new Date(value);
|
|
22
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
23
|
+
}
|
|
24
|
+
function eventCalendarDayBounds(event) {
|
|
25
|
+
const startDateTime = asDate(event.startDateTime);
|
|
26
|
+
if (!startDateTime) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const zone = resolveEventTimezoneIanaForDisplay({
|
|
30
|
+
timezone: event.timezone,
|
|
31
|
+
city: event.city,
|
|
32
|
+
state: event.state,
|
|
33
|
+
country: event.country,
|
|
34
|
+
});
|
|
35
|
+
const endInstant = asDate(event.endDateTime) ?? startDateTime;
|
|
36
|
+
const endZ = DateTime.fromJSDate(endInstant, { zone: "utc" }).setZone(zone);
|
|
37
|
+
return {
|
|
38
|
+
// All-night (no explicit quest window) opens at the event start, not midnight.
|
|
39
|
+
startsAt: startDateTime,
|
|
40
|
+
endsAt: endZ.endOf("day").toUTC().toJSDate(),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Unscheduled quests run from the event start through the end of that local night. Explicit quest windows override. */
|
|
44
|
+
export function sideQuestWindow(quest, event) {
|
|
45
|
+
if (quest.startsAt != null || quest.endsAt != null) {
|
|
46
|
+
return {
|
|
47
|
+
startsAt: quest.startsAt ?? null,
|
|
48
|
+
endsAt: quest.endsAt ?? null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const bounds = event ? eventCalendarDayBounds(event) : null;
|
|
52
|
+
if (!bounds) {
|
|
53
|
+
return { startsAt: null, endsAt: null };
|
|
54
|
+
}
|
|
55
|
+
return bounds;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=sideQuestWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sideQuestWindow.js","sourceRoot":"","sources":["../src/sideQuestWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAElF,MAAM,8BAA8B,GAA4B,IAAI,GAAG,CAAC;IACtE,UAAU,CAAC,IAAI;IACf,UAAU,CAAC,KAAK;IAChB,UAAU,CAAC,OAAO;IAClB,UAAU,CAAC,QAAQ;IACnB,UAAU,CAAC,SAAS;IACpB,UAAU,CAAC,QAAQ;CACpB,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,UAAU,+BAA+B,CAC7C,MAAqC;IAErC,OAAO,MAAM,IAAI,IAAI,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACvE,CAAC;AAaD,SAAS,MAAM,CAAC,KAAuC;IACrD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAA2B;IAE3B,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,kCAAkC,CAAC;QAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,OAAO;QACL,+EAA+E;QAC/E,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;KAC7C,CAAC;AACJ,CAAC;AAED,wHAAwH;AACxH,MAAM,UAAU,eAAe,CAC7B,KAAa,EACb,KAAmC;IAEnC,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACnD,OAAO;YACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;YAChC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;SAC7B,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plainListingHeadline.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/plainListingHeadline.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { listingHeadlineContainsHtml, plainListingHeadline, } from "../plainListingHeadline";
|
|
2
|
+
describe("plainListingHeadline", () => {
|
|
3
|
+
it("strips HTML tags", () => {
|
|
4
|
+
expect(plainListingHeadline("<b>Best</b>")).toBe("Best");
|
|
5
|
+
});
|
|
6
|
+
it("leaves plain text unchanged", () => {
|
|
7
|
+
expect(plainListingHeadline("Neon nights")).toBe("Neon nights");
|
|
8
|
+
});
|
|
9
|
+
it("detects markup", () => {
|
|
10
|
+
expect(listingHeadlineContainsHtml("x")).toBe(false);
|
|
11
|
+
expect(listingHeadlineContainsHtml("<i>x</i>")).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=plainListingHeadline.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plainListingHeadline.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/plainListingHeadline.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAEjC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC1B,MAAM,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,2BAA2B,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { validateOptionalWebLink } from "../webLinkValidation.js";
|
|
|
2
2
|
it.each([undefined, null, "", "https://meet.example.com/room?key=123", "http://example.com"])("accepts an optional web link %s", value => {
|
|
3
3
|
expect(validateOptionalWebLink(value)).toBeNull();
|
|
4
4
|
});
|
|
5
|
-
it.each(["javascript:alert(1)", "data:text/html,hello", "file:///tmp/test", "not a url", "https://user:password@example.com", 123])("rejects invalid or unsafe links %s", value => {
|
|
5
|
+
it.each(["javascript:alert(1)", "data:text/html,hello", "file:///tmp/test", "not a url", "https://notaurl", "https://user:password@example.com", 123])("rejects invalid or unsafe links %s", value => {
|
|
6
6
|
expect(validateOptionalWebLink(value)).toContain("https://");
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=webLinkValidation.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webLinkValidation.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/webLinkValidation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,uCAAuC,EAAE,oBAAoB,CAAC,CAAC,CAAC,iCAAiC,EAAE,KAAK,CAAC,EAAE;IACvI,MAAM,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,WAAW,EAAE,mCAAmC,EAAE,GAAG,CAAC,CAAC,CAAC,oCAAoC,EAAE,KAAK,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"webLinkValidation.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/webLinkValidation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,uCAAuC,EAAE,oBAAoB,CAAC,CAAC,CAAC,iCAAiC,EAAE,KAAK,CAAC,EAAE;IACvI,MAAM,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,mCAAmC,EAAE,GAAG,CAAC,CAAC,CAAC,oCAAoC,EAAE,KAAK,CAAC,EAAE;IACnM,MAAM,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Bash listing names (title/subtitle) are plain text — no HTML markup. */
|
|
2
|
+
/** Strip common HTML pasted into title fields; decode a few entities. */
|
|
3
|
+
export declare function plainListingHeadline(value: string): string;
|
|
4
|
+
export declare function listingHeadlineContainsHtml(value: string): boolean;
|
|
5
|
+
//# sourceMappingURL=plainListingHeadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plainListingHeadline.d.ts","sourceRoot":"","sources":["../../src/utils/plainListingHeadline.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAI3E,yEAAyE;AACzE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY1D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Bash listing names (title/subtitle) are plain text — no HTML markup. */
|
|
2
|
+
const HTML_TAG_PATTERN = /<[a-z!/][^>]*>/i;
|
|
3
|
+
/** Strip common HTML pasted into title fields; decode a few entities. */
|
|
4
|
+
export function plainListingHeadline(value) {
|
|
5
|
+
if (!HTML_TAG_PATTERN.test(value)) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return value
|
|
9
|
+
.replace(/<[^>]*>/g, "")
|
|
10
|
+
.replace(/ /gi, " ")
|
|
11
|
+
.replace(/&/g, "&")
|
|
12
|
+
.replace(/</g, "<")
|
|
13
|
+
.replace(/>/g, ">")
|
|
14
|
+
.replace(/"/g, '"')
|
|
15
|
+
.replace(/'/g, "'");
|
|
16
|
+
}
|
|
17
|
+
export function listingHeadlineContainsHtml(value) {
|
|
18
|
+
return HTML_TAG_PATTERN.test(value);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=plainListingHeadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plainListingHeadline.js","sourceRoot":"","sources":["../../src/utils/plainListingHeadline.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,yEAAyE;AACzE,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK;SACT,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAa;IACvD,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webLinkValidation.d.ts","sourceRoot":"","sources":["../../src/utils/webLinkValidation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"webLinkValidation.d.ts","sourceRoot":"","sources":["../../src/utils/webLinkValidation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAmBrE"}
|
|
@@ -6,8 +6,14 @@ export function validateOptionalWebLink(value) {
|
|
|
6
6
|
return "Enter a full web link starting with https:// or http://.";
|
|
7
7
|
try {
|
|
8
8
|
const url = new URL(value.trim());
|
|
9
|
-
|
|
9
|
+
const hostname = url.hostname;
|
|
10
|
+
if ((url.protocol === "https:" || url.protocol === "http:") &&
|
|
11
|
+
hostname &&
|
|
12
|
+
(hostname === "localhost" || hostname.includes(".")) &&
|
|
13
|
+
!url.username &&
|
|
14
|
+
!url.password) {
|
|
10
15
|
return null;
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
catch {
|
|
13
19
|
// Invalid URLs receive the same actionable message as unsupported schemes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webLinkValidation.js","sourceRoot":"","sources":["../../src/utils/webLinkValidation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,0DAA0D,CAAC;IACjG,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,
|
|
1
|
+
{"version":3,"file":"webLinkValidation.js","sourceRoot":"","sources":["../../src/utils/webLinkValidation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,0DAA0D,CAAC;IACjG,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,IACE,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;YACvD,QAAQ;YACR,CAAC,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpD,CAAC,GAAG,CAAC,QAAQ;YACb,CAAC,GAAG,CAAC,QAAQ,EACb,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;IAC7E,CAAC;IACD,OAAO,0DAA0D,CAAC;AACpE,CAAC"}
|
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -4349,9 +4349,9 @@ model AmountOfGuests {
|
|
|
4349
4349
|
minimum Int?
|
|
4350
4350
|
ideal Int?
|
|
4351
4351
|
expected Int?
|
|
4352
|
-
showMinimumGuests Boolean @default(
|
|
4353
|
-
showIdealGuests Boolean @default(
|
|
4354
|
-
showExpectedGuests Boolean @default(
|
|
4352
|
+
showMinimumGuests Boolean @default(false)
|
|
4353
|
+
showIdealGuests Boolean @default(false)
|
|
4354
|
+
showExpectedGuests Boolean @default(false)
|
|
4355
4355
|
maximum Int?
|
|
4356
4356
|
showMaximumGuests Boolean @default(false)
|
|
4357
4357
|
autoCancelIfMinNotMet Boolean @default(false)
|
|
@@ -5073,6 +5073,7 @@ model User {
|
|
|
5073
5073
|
warmIntroOffersAsPartyA WarmIntroOffer[] @relation("WarmIntroOfferPartyA")
|
|
5074
5074
|
warmIntroOffersAsPartyB WarmIntroOffer[] @relation("WarmIntroOfferPartyB")
|
|
5075
5075
|
facilitatedIntroductions Introduction[] @relation("IntroFacilitator")
|
|
5076
|
+
introductionMemberships IntroductionMember[] @relation("IntroductionMemberUser")
|
|
5076
5077
|
links UserLink[]
|
|
5077
5078
|
preferences UserPreferences?
|
|
5078
5079
|
rankings UserRankings?
|
|
@@ -5841,7 +5842,7 @@ model IntrosPair {
|
|
|
5841
5842
|
|
|
5842
5843
|
model Introduction {
|
|
5843
5844
|
id String @id @default(cuid())
|
|
5844
|
-
pairId String
|
|
5845
|
+
pairId String?
|
|
5845
5846
|
bashEventId String?
|
|
5846
5847
|
source IntroductionSource
|
|
5847
5848
|
mode IntroductionMode
|
|
@@ -5871,7 +5872,8 @@ model Introduction {
|
|
|
5871
5872
|
expiresAt DateTime?
|
|
5872
5873
|
version Int @default(0)
|
|
5873
5874
|
createdAt DateTime @default(now())
|
|
5874
|
-
pair IntrosPair
|
|
5875
|
+
pair IntrosPair? @relation(fields: [pairId], references: [id], onDelete: Cascade)
|
|
5876
|
+
members IntroductionMember[]
|
|
5875
5877
|
bashEvent BashEvent? @relation(fields: [bashEventId], references: [id], onDelete: SetNull)
|
|
5876
5878
|
facilitator User? @relation("IntroFacilitator", fields: [facilitatorId], references: [id], onDelete: SetNull)
|
|
5877
5879
|
earlyReveals EarlyRevealRequest[]
|
|
@@ -5882,6 +5884,20 @@ model Introduction {
|
|
|
5882
5884
|
@@index([state, revealAt])
|
|
5883
5885
|
}
|
|
5884
5886
|
|
|
5887
|
+
model IntroductionMember {
|
|
5888
|
+
id String @id @default(cuid())
|
|
5889
|
+
introductionId String
|
|
5890
|
+
userId String
|
|
5891
|
+
interest IntroInterest @default(Pending)
|
|
5892
|
+
interestAt DateTime?
|
|
5893
|
+
saidHiAt DateTime?
|
|
5894
|
+
introduction Introduction @relation(fields: [introductionId], references: [id], onDelete: Cascade)
|
|
5895
|
+
user User @relation("IntroductionMemberUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
5896
|
+
|
|
5897
|
+
@@unique([introductionId, userId])
|
|
5898
|
+
@@index([userId])
|
|
5899
|
+
}
|
|
5900
|
+
|
|
5885
5901
|
model WarmIntroSuggestion {
|
|
5886
5902
|
id String @id @default(cuid())
|
|
5887
5903
|
facilitatorId String
|
|
@@ -112,6 +112,11 @@ describe("membershipDefinitions helpers", () => {
|
|
|
112
112
|
expect(hasReachedFeatureLimit(MembershipTier.Pro, "featuredEvents", 1)).toBe(true);
|
|
113
113
|
expect(hasReachedFeatureLimit(MembershipTier.Pro, "featuredEvents", 0)).toBe(false);
|
|
114
114
|
});
|
|
115
|
+
|
|
116
|
+
test("Legend tier blocks at five featured events", () => {
|
|
117
|
+
expect(hasReachedFeatureLimit(MembershipTier.Legend, "featuredEvents", 5)).toBe(true);
|
|
118
|
+
expect(hasReachedFeatureLimit(MembershipTier.Legend, "featuredEvents", 4)).toBe(false);
|
|
119
|
+
});
|
|
115
120
|
});
|
|
116
121
|
|
|
117
122
|
test("Basic tier promo code cap constant", () => {
|
|
@@ -30,9 +30,17 @@ describe("partnerBookingAgreement", () => {
|
|
|
30
30
|
},
|
|
31
31
|
} as never);
|
|
32
32
|
expect(snapshot?.role).toBe("vendor");
|
|
33
|
+
expect(snapshot?.accepts).toBe(true);
|
|
33
34
|
expect(snapshot?.displayText).toContain("STANDARD VENDOR BOOKING AGREEMENT");
|
|
34
35
|
});
|
|
35
36
|
|
|
37
|
+
it("treats missing vendor agreement acceptance as not accepted", () => {
|
|
38
|
+
const snapshot = readPartnerBookingAgreementFromService({
|
|
39
|
+
vendor: { preferences: {} },
|
|
40
|
+
} as never);
|
|
41
|
+
expect(snapshot?.accepts).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
36
44
|
it("reads exhibitor agreement from flat exhibitor fields", () => {
|
|
37
45
|
const snapshot = readPartnerBookingAgreementFromService({
|
|
38
46
|
exhibitor: {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BashStatus } from "@prisma/client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
bashAcceptsSideQuestCompletions,
|
|
5
|
+
sideQuestWindow,
|
|
6
|
+
} from "../sideQuestWindow.js";
|
|
7
|
+
|
|
8
|
+
it.each([
|
|
9
|
+
[BashStatus.Draft, false],
|
|
10
|
+
[BashStatus.Idea, false],
|
|
11
|
+
[BashStatus.Pending, false],
|
|
12
|
+
[BashStatus.Rejected, false],
|
|
13
|
+
[BashStatus.Cancelled, false],
|
|
14
|
+
[BashStatus.Archived, false],
|
|
15
|
+
[BashStatus.Published, true],
|
|
16
|
+
[BashStatus.PreSale, true],
|
|
17
|
+
[BashStatus.Finished, true],
|
|
18
|
+
[null, true],
|
|
19
|
+
])("bash status %s accepts quest completions: %s", (status, expected) => {
|
|
20
|
+
expect(bashAcceptsSideQuestCompletions(status)).toBe(expected);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("opens an unscheduled quest at the event start and keeps it open through that local night", () => {
|
|
24
|
+
const startDateTime = new Date("2030-11-02T19:00:00Z");
|
|
25
|
+
const endDateTime = new Date("2030-11-02T22:00:00Z");
|
|
26
|
+
const window = sideQuestWindow(
|
|
27
|
+
{ startsAt: null, endsAt: null },
|
|
28
|
+
{ startDateTime, endDateTime, timezone: "America/New_York" }
|
|
29
|
+
);
|
|
30
|
+
expect(window.startsAt?.toISOString()).toBe("2030-11-02T19:00:00.000Z");
|
|
31
|
+
expect(window.endsAt?.toISOString()).toBe("2030-11-03T03:59:59.999Z");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("preserves an explicitly scheduled pre-event quest", () => {
|
|
35
|
+
const startsAt = new Date("2030-11-01T19:00:00Z");
|
|
36
|
+
expect(
|
|
37
|
+
sideQuestWindow(
|
|
38
|
+
{ startsAt },
|
|
39
|
+
{ startDateTime: new Date("2030-11-02T19:00:00Z") }
|
|
40
|
+
).startsAt
|
|
41
|
+
).toBe(startsAt);
|
|
42
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./extendedSchemas.js";
|
|
|
18
18
|
export * from "./competitionIdeas.js";
|
|
19
19
|
export * from "./sideQuestIdeas.js";
|
|
20
20
|
export * from "./sideQuestTypes.js";
|
|
21
|
+
export * from "./sideQuestWindow.js";
|
|
21
22
|
export * from "./icebreakerPrompts.js";
|
|
22
23
|
export * from "./causeTags.js";
|
|
23
24
|
export * from "./discoveryScope.js";
|
|
@@ -506,6 +507,7 @@ export * from "./utils/ticketTierValidation.js";
|
|
|
506
507
|
|
|
507
508
|
export * from "./utils/organizationMembershipValidation";
|
|
508
509
|
export * from "./utils/crowdSizeValidation.js";
|
|
510
|
+
export * from "./utils/plainListingHeadline.js";
|
|
509
511
|
export * from "./utils/webLinkValidation.js";
|
|
510
512
|
export * from "./utils/listingContactValidation.js";
|
|
511
513
|
export * from "./utils/p2pPaymentValidation.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { introRevealAt } from "../revealClock.js";
|
|
2
|
+
|
|
3
|
+
describe("introRevealAt", () => {
|
|
4
|
+
const start = new Date("2026-11-09T20:00:00.000Z");
|
|
5
|
+
|
|
6
|
+
it("uses the midpoint when the bash has an end", () => {
|
|
7
|
+
const end = new Date("2026-11-10T00:00:00.000Z");
|
|
8
|
+
expect(introRevealAt(start, end)?.toISOString()).toBe("2026-11-09T22:00:00.000Z");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses one hour after start when there is no end", () => {
|
|
12
|
+
expect(introRevealAt(start, null)?.toISOString()).toBe("2026-11-09T21:00:00.000Z");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns null when there is no start", () => {
|
|
16
|
+
expect(introRevealAt(null, null)).toBeNull();
|
|
17
|
+
});
|
|
18
|
+
});
|
package/src/intros/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
2
|
+
|
|
3
|
+
function asDate(value: Date | string | null | undefined): Date | null {
|
|
4
|
+
if (!value) return null;
|
|
5
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
6
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* When names become visible. Midpoint of the bash, or one hour after start
|
|
11
|
+
* when the bash has no end. No bash means there is no clock.
|
|
12
|
+
*/
|
|
13
|
+
export function introRevealAt(
|
|
14
|
+
start: Date | string | null | undefined,
|
|
15
|
+
end: Date | string | null | undefined
|
|
16
|
+
): Date | null {
|
|
17
|
+
const startAt = asDate(start);
|
|
18
|
+
if (!startAt) return null;
|
|
19
|
+
const endAt = asDate(end);
|
|
20
|
+
if (endAt && endAt.getTime() > startAt.getTime()) {
|
|
21
|
+
return new Date(startAt.getTime() + (endAt.getTime() - startAt.getTime()) / 2);
|
|
22
|
+
}
|
|
23
|
+
return new Date(startAt.getTime() + HOUR_MS);
|
|
24
|
+
}
|
|
@@ -910,9 +910,13 @@ export function hasReachedFeatureLimit(
|
|
|
910
910
|
const tierInfo = MEMBERSHIP_TIER_INFO[userTier];
|
|
911
911
|
|
|
912
912
|
switch (feature) {
|
|
913
|
-
case "featuredEvents":
|
|
913
|
+
case "featuredEvents": {
|
|
914
914
|
const limit = tierInfo.limits.featuredEventsPerMonth;
|
|
915
|
-
|
|
915
|
+
if (limit === undefined) return false;
|
|
916
|
+
if (limit === -1) return false;
|
|
917
|
+
if (limit === 0) return currentUsage > 0;
|
|
918
|
+
return currentUsage >= limit;
|
|
919
|
+
}
|
|
916
920
|
default:
|
|
917
921
|
return false;
|
|
918
922
|
}
|
|
@@ -315,7 +315,7 @@ export function readPartnerBookingAgreementFromService(
|
|
|
315
315
|
return {
|
|
316
316
|
role: "vendor",
|
|
317
317
|
roleLabel: partnerBookingAgreementRoleLabel("vendor"),
|
|
318
|
-
accepts: prefs?.acceptsVendorBookingTerms
|
|
318
|
+
accepts: prefs?.acceptsVendorBookingTerms === true,
|
|
319
319
|
displayText: getVendorBookingAgreementDisplayText(
|
|
320
320
|
prefs?.vendorBookingAgreementText
|
|
321
321
|
),
|
package/src/sideQuestTypes.ts
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { TICKET_DETAILS } from "./definitions.js";
|
|
6
6
|
import type { SideQuestCategoryId, SideQuestTypeId } from "./sideQuestIdeas.js";
|
|
7
|
+
import type { SideQuestEventWindow } from "./sideQuestWindow.js";
|
|
8
|
+
|
|
9
|
+
export type { SideQuestEventWindow };
|
|
7
10
|
|
|
8
11
|
export interface EventBadgeExt {
|
|
9
12
|
id: string;
|
|
@@ -105,6 +108,8 @@ export interface CommunityQuestGoalExt {
|
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
export interface SideQuestLogExt {
|
|
111
|
+
/** Event schedule used to derive default quest windows on the client (quest-log API). */
|
|
112
|
+
eventWindow?: SideQuestEventWindow | null;
|
|
108
113
|
quests: SideQuestExt[];
|
|
109
114
|
availableCount: number;
|
|
110
115
|
completedCount: number;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BashStatus } from "@prisma/client";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
|
|
4
|
+
import { resolveEventTimezoneIanaForDisplay } from "./utils/eventTimezoneIana.js";
|
|
5
|
+
|
|
6
|
+
const BASH_STATUSES_CLOSED_TO_QUESTS: ReadonlySet<BashStatus> = new Set([
|
|
7
|
+
BashStatus.Idea,
|
|
8
|
+
BashStatus.Draft,
|
|
9
|
+
BashStatus.Pending,
|
|
10
|
+
BashStatus.Rejected,
|
|
11
|
+
BashStatus.Cancelled,
|
|
12
|
+
BashStatus.Archived,
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
/** Unpublished, rejected, or cancelled bashes never award quest completions. */
|
|
16
|
+
export function bashAcceptsSideQuestCompletions(
|
|
17
|
+
status: BashStatus | null | undefined
|
|
18
|
+
): boolean {
|
|
19
|
+
return status == null || !BASH_STATUSES_CLOSED_TO_QUESTS.has(status);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Window = { startsAt?: Date | null; endsAt?: Date | null };
|
|
23
|
+
|
|
24
|
+
export type SideQuestEventWindow = {
|
|
25
|
+
startDateTime?: Date | string | null;
|
|
26
|
+
endDateTime?: Date | string | null;
|
|
27
|
+
timezone?: string | null;
|
|
28
|
+
city?: string | null;
|
|
29
|
+
state?: string | null;
|
|
30
|
+
country?: string | null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function asDate(value: Date | string | null | undefined): Date | null {
|
|
34
|
+
if (value == null) return null;
|
|
35
|
+
if (value instanceof Date) return value;
|
|
36
|
+
const parsed = new Date(value);
|
|
37
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function eventCalendarDayBounds(
|
|
41
|
+
event: SideQuestEventWindow
|
|
42
|
+
): { startsAt: Date; endsAt: Date } | null {
|
|
43
|
+
const startDateTime = asDate(event.startDateTime);
|
|
44
|
+
if (!startDateTime) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const zone = resolveEventTimezoneIanaForDisplay({
|
|
48
|
+
timezone: event.timezone,
|
|
49
|
+
city: event.city,
|
|
50
|
+
state: event.state,
|
|
51
|
+
country: event.country,
|
|
52
|
+
});
|
|
53
|
+
const endInstant = asDate(event.endDateTime) ?? startDateTime;
|
|
54
|
+
const endZ = DateTime.fromJSDate(endInstant, { zone: "utc" }).setZone(zone);
|
|
55
|
+
return {
|
|
56
|
+
// All-night (no explicit quest window) opens at the event start, not midnight.
|
|
57
|
+
startsAt: startDateTime,
|
|
58
|
+
endsAt: endZ.endOf("day").toUTC().toJSDate(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Unscheduled quests run from the event start through the end of that local night. Explicit quest windows override. */
|
|
63
|
+
export function sideQuestWindow(
|
|
64
|
+
quest: Window,
|
|
65
|
+
event?: SideQuestEventWindow | null
|
|
66
|
+
) {
|
|
67
|
+
if (quest.startsAt != null || quest.endsAt != null) {
|
|
68
|
+
return {
|
|
69
|
+
startsAt: quest.startsAt ?? null,
|
|
70
|
+
endsAt: quest.endsAt ?? null,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const bounds = event ? eventCalendarDayBounds(event) : null;
|
|
75
|
+
if (!bounds) {
|
|
76
|
+
return { startsAt: null, endsAt: null };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return bounds;
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listingHeadlineContainsHtml,
|
|
3
|
+
plainListingHeadline,
|
|
4
|
+
} from "../plainListingHeadline";
|
|
5
|
+
|
|
6
|
+
describe("plainListingHeadline", () => {
|
|
7
|
+
it("strips HTML tags", () => {
|
|
8
|
+
expect(plainListingHeadline("<b>Best</b>")).toBe("Best");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("leaves plain text unchanged", () => {
|
|
12
|
+
expect(plainListingHeadline("Neon nights")).toBe("Neon nights");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("detects markup", () => {
|
|
16
|
+
expect(listingHeadlineContainsHtml("x")).toBe(false);
|
|
17
|
+
expect(listingHeadlineContainsHtml("<i>x</i>")).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -3,6 +3,6 @@ import { validateOptionalWebLink } from "../webLinkValidation.js";
|
|
|
3
3
|
it.each([undefined, null, "", "https://meet.example.com/room?key=123", "http://example.com"])("accepts an optional web link %s", value => {
|
|
4
4
|
expect(validateOptionalWebLink(value)).toBeNull();
|
|
5
5
|
});
|
|
6
|
-
it.each(["javascript:alert(1)", "data:text/html,hello", "file:///tmp/test", "not a url", "https://user:password@example.com", 123])("rejects invalid or unsafe links %s", value => {
|
|
6
|
+
it.each(["javascript:alert(1)", "data:text/html,hello", "file:///tmp/test", "not a url", "https://notaurl", "https://user:password@example.com", 123])("rejects invalid or unsafe links %s", value => {
|
|
7
7
|
expect(validateOptionalWebLink(value)).toContain("https://");
|
|
8
8
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Bash listing names (title/subtitle) are plain text — no HTML markup. */
|
|
2
|
+
|
|
3
|
+
const HTML_TAG_PATTERN = /<[a-z!/][^>]*>/i;
|
|
4
|
+
|
|
5
|
+
/** Strip common HTML pasted into title fields; decode a few entities. */
|
|
6
|
+
export function plainListingHeadline(value: string): string {
|
|
7
|
+
if (!HTML_TAG_PATTERN.test(value)) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return value
|
|
11
|
+
.replace(/<[^>]*>/g, "")
|
|
12
|
+
.replace(/ /gi, " ")
|
|
13
|
+
.replace(/&/g, "&")
|
|
14
|
+
.replace(/</g, "<")
|
|
15
|
+
.replace(/>/g, ">")
|
|
16
|
+
.replace(/"/g, '"')
|
|
17
|
+
.replace(/'/g, "'");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function listingHeadlineContainsHtml(value: string): boolean {
|
|
21
|
+
return HTML_TAG_PATTERN.test(value);
|
|
22
|
+
}
|
|
@@ -4,7 +4,16 @@ export function validateOptionalWebLink(value: unknown): string | null {
|
|
|
4
4
|
if (typeof value !== "string") return "Enter a full web link starting with https:// or http://.";
|
|
5
5
|
try {
|
|
6
6
|
const url = new URL(value.trim());
|
|
7
|
-
|
|
7
|
+
const hostname = url.hostname;
|
|
8
|
+
if (
|
|
9
|
+
(url.protocol === "https:" || url.protocol === "http:") &&
|
|
10
|
+
hostname &&
|
|
11
|
+
(hostname === "localhost" || hostname.includes(".")) &&
|
|
12
|
+
!url.username &&
|
|
13
|
+
!url.password
|
|
14
|
+
) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
8
17
|
} catch {
|
|
9
18
|
// Invalid URLs receive the same actionable message as unsupported schemes.
|
|
10
19
|
}
|