File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -36,4 +36,23 @@ describe("getFeatureUrl", () => {
36
36
"https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?patient[id]=patientId&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost"
37
37
) ;
38
38
} ) ;
39
+
40
+ it ( "returns proper custom url if domain is present" , ( ) => {
41
+ const customDomain = "https://staging.r.fullscript.io" ;
42
+ mockFullscriptOptions = {
43
+ ...mockFullscriptOptions ,
44
+ domain : customDomain ,
45
+ } ;
46
+
47
+ const url = getFeatureURL (
48
+ "treatmentPlan" ,
49
+ mockFeatureOptions ,
50
+ mockFullscriptOptions ,
51
+ mockFrameId
52
+ ) ;
53
+
54
+ expect ( url ) . toEqual (
55
+ `${ customDomain } /api/embeddable/session/treatment_plans/new?patient[id]=patientId&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
56
+ ) ;
57
+ } ) ;
39
58
} ) ;
Original file line number Diff line number Diff line change @@ -11,11 +11,12 @@ const getFeatureURL = <F extends FeatureType>(
11
11
fullscriptOptions : FullscriptOptions ,
12
12
frameId : string
13
13
) : string => {
14
- const { publicKey, env } = fullscriptOptions ;
14
+ const { publicKey, env, domain } = fullscriptOptions ;
15
15
const queryString = buildQueryString ( { ...featureOptions , publicKey, frameId } ) ;
16
16
validateFeatureType ( featureType ) ;
17
+ const fsDomain = domain ? domain : FULLSCRIPT_DOMAINS [ env ] ;
17
18
18
- return `${ FULLSCRIPT_DOMAINS [ env ] } /api/embeddable/session${ FEATURE_PATHS [ featureType ] } ${ queryString } &target_origin=${ window . location . origin } ` ;
19
+ return `${ fsDomain } /api/embeddable/session${ FEATURE_PATHS [ featureType ] } ${ queryString } &target_origin=${ window . location . origin } ` ;
19
20
} ;
20
21
21
22
export { getFeatureURL } ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const FULLSCRIPT_DOMAINS: { [key: string]: FullscriptDomain } = {
14
14
} ;
15
15
16
16
type FullscriptEnv = "us" | "ca" | "us-snd" | "ca-snd" | "dev" ;
17
- type FullscriptOptions = { publicKey : string ; env : FullscriptEnv } ;
17
+ type FullscriptOptions = { publicKey : string ; env : FullscriptEnv ; domain ?: string } ;
18
18
19
19
export { FULLSCRIPT_DOMAINS } ;
20
20
export type { FullscriptEnv , FullscriptOptions , FullscriptDomain } ;
You can’t perform that action at this time.
0 commit comments