File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
extensions/blocks/opentable Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import { getAttributesFromEmbedCode } from '../utils';
9
9
10
10
const widgetEmbedCode = "<script type='text/javascript' src='//www.opentable.com/widget/reservation/loader?rid=1&type=standard&theme=standard&iframe=true&domain=com&lang=en-US&newtab=false&ot_source=Restaurant%20website'></script>" ;
11
11
12
+ const invalidEmbedCode = "<script type='text/javascript' src='https://www.widgets-r-us.com/widget/widgetygoddness?rid=1&type=standard&theme=standard&iframe=true&domain=com&lang=en-US&newtab=false&ot_source=Restaurant%20website'></script>" ;
13
+
12
14
const marketingUrl = "https://www.opentable.com/vongs-thai-kitchen-reservations-chicago?restref=1&lang=en-US&ot_source=Restaurant%20website" ;
13
15
14
16
const customUrl1 = "https://www.opentable.com/restref/client/?restref=412810&lang=en-US&ot_source=Restaurant%20website&corrid=e413926b-0352-46d6-a8d8-d1d525932310" ;
@@ -17,6 +19,8 @@ const customUrl2 = "https://www.opentable.com/restref/client/?restref=1&lang=es-
17
19
18
20
const customUrl3 = "https://www.opentable.com/restref/client/?rid=1&corrid=010a3136-569e-42a5-a381-e111887b4cf5" ;
19
21
22
+ const invalidUrl = "https://www.widgets-r-us.com/widget/widgetygoddness?rid=1&type=standard&theme=standard&iframe=true&domain=com&lang=en-US&newtab=false&ot_source=Restaurant%20website" ;
23
+
20
24
describe ( 'getAttributesFromEmbedCode' , ( ) => {
21
25
test ( 'Widget embed code' , ( ) => {
22
26
expect (
@@ -75,4 +79,16 @@ describe( 'getAttributesFromEmbedCode', () => {
75
79
}
76
80
) ;
77
81
} ) ;
82
+
83
+ test ( 'Invaild Embed Code' , ( ) => {
84
+ expect (
85
+ getAttributesFromEmbedCode ( invalidEmbedCode )
86
+ ) . toBeUndefined ( ) ;
87
+ } ) ;
88
+
89
+ test ( 'Invaild URL' , ( ) => {
90
+ expect (
91
+ getAttributesFromEmbedCode ( invalidUrl )
92
+ ) . toBeUndefined ( ) ;
93
+ } ) ;
78
94
} ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const getAttributesFromUrl = url => {
10
10
src = new URL ( 'http:' + url ) ;
11
11
}
12
12
13
- if ( ! src . search ) {
13
+ if ( ! src . host || src . host . indexOf ( 'opentable' ) === - 1 || ! src . search ) {
14
14
return ;
15
15
}
16
16
You can’t perform that action at this time.
0 commit comments