File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
packages/commons/docs-utils/src Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 11import { extractOrgFromPreview , isPreviewDomain } from "../isPreviewUrl" ;
22
33describe ( "isPreviewDomain" , ( ) => {
4- it ( "should return true for valid preview domains" , ( ) => {
4+ it ( "should return true for preview domains with truncated UUIDs " , ( ) => {
55 const validDomains = [
6- "fern-12345678-1234-1234-1234-123456789012.docs.buildwithfern.com" ,
7- "acme-abcdef01-2345-6789-abcd-ef0123456789.docs.buildwithfern.com" ,
6+ "payabli-preview-fad23292-87bd-4eec-bf26-.docs.buildwithfern.com" ,
87 ] ;
98
109 validDomains . forEach ( ( domain ) => {
Original file line number Diff line number Diff line change 11export function isPreviewDomain ( domain : string ) : boolean {
2- const uuidRegex =
3- "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" ;
4- return new RegExp ( `^.*?${ uuidRegex } \\.docs\\.buildwithfern\\.com$` ) . test (
5- domain
6- ) ;
2+ // Accepts org-preview-<uuid-or-truncated-uuid>.docs.buildwithfern.com
3+ // The uuid part can be truncated, so allow trailing dash and partial uuid
4+ const previewUuidPattern = / p r e v i e w - [ 0 - 9 a - f - ] + / i;
5+ const hasPattern = previewUuidPattern . test ( domain ) ;
6+ // Add logs for debugging
7+ if ( typeof console !== "undefined" && typeof console . log === "function" ) {
8+ console . log ( `[isPreviewDomain] Checking domain: ${ domain } ` ) ;
9+ console . log ( `[isPreviewDomain] Pattern: ${ previewUuidPattern } ` ) ;
10+ console . log ( `[isPreviewDomain] Match result: ${ hasPattern } ` ) ;
11+ }
12+ return hasPattern ;
713}
814
915export function extractOrgFromPreview ( domain : string ) : string | undefined {
You can’t perform that action at this time.
0 commit comments