@devvit/public-api 0.11.17-next-2025-06-02-50427ee57.0 → 0.11.17-next-2025-06-02-02cef9c33.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.
@@ -1,14 +0,0 @@
1
- /**
2
- * Asserts that the number of requested fetch domains is within the allowed limit.
3
- * @param requestedFetchDomains - The array of requested fetch domains.
4
- * @throws Error if the number of domains exceeds the limit.
5
- */
6
- export declare function assertRequestedFetchDomainsLimit(requestedFetchDomains: string[]): void;
7
- /**
8
- * Normalizes the requested fetch domains by removing the protocol and 'www' prefix if present.
9
- * @param requestedFetchDomains - The array of requested fetch domains.
10
- * @returns An array of normalized domains.
11
- * @throws Error if any domain format is invalid.
12
- */
13
- export declare function normalizeDomains(requestedFetchDomains: string[]): string[];
14
- //# sourceMappingURL=fetchDomains.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchDomains.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/helpers/fetchDomains.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,IAAI,CAItF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA4B1E"}
@@ -1,42 +0,0 @@
1
- // Regular expression to check if a domain contains a top-level domain, eg '.com' or '.org'
2
- const TOP_LEVEL_DOMAIN_REGEX = /\.[a-zA-Z]{2,}$/;
3
- const MAX_DOMAINS = 25;
4
- /**
5
- * Asserts that the number of requested fetch domains is within the allowed limit.
6
- * @param requestedFetchDomains - The array of requested fetch domains.
7
- * @throws Error if the number of domains exceeds the limit.
8
- */
9
- export function assertRequestedFetchDomainsLimit(requestedFetchDomains) {
10
- if (requestedFetchDomains.length > MAX_DOMAINS) {
11
- throw new Error(`The size of requestedFetchDomains is limited to ${MAX_DOMAINS} domains.`);
12
- }
13
- }
14
- /**
15
- * Normalizes the requested fetch domains by removing the protocol and 'www' prefix if present.
16
- * @param requestedFetchDomains - The array of requested fetch domains.
17
- * @returns An array of normalized domains.
18
- * @throws Error if any domain format is invalid.
19
- */
20
- export function normalizeDomains(requestedFetchDomains) {
21
- const normalizedSet = new Set();
22
- for (let rawDomain of requestedFetchDomains) {
23
- try {
24
- // Check for valid TLD (like '.com', '.net', etc.)
25
- if (!TOP_LEVEL_DOMAIN_REGEX.test(rawDomain)) {
26
- throw new Error(`The domain does not have a valid top-level domain.`);
27
- }
28
- // Prepend 'http://' if no protocol is present
29
- if (!rawDomain.includes('://')) {
30
- rawDomain = 'http://' + rawDomain;
31
- }
32
- // Create URL object and extract hostname
33
- const url = new URL(rawDomain);
34
- const normalizedDomain = url.hostname.replace(/^www\./, ''); // Remove 'www.' prefix
35
- normalizedSet.add(normalizedDomain);
36
- }
37
- catch (error) {
38
- throw new Error(`Failed to determine hostname from requested domain: '${rawDomain}'. ${error}`);
39
- }
40
- }
41
- return Array.from(normalizedSet);
42
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchDomains.test.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/helpers/fetchDomains.test.ts"],"names":[],"mappings":""}