@@ -126,6 +126,50 @@ describe('dev proxy', () => {
126126 `"<https://cdn.shopify.com>; rel=\\"preconnect\\", <https://cdn.shopify.com>; rel=\\"preconnect\\"; crossorigin,</cdn/shop/t/10/assets/component-localization-form.css?v=120620094879297847921723560016>; as=\\"style\\"; rel=\\"preload\\""` ,
127127 )
128128 } )
129+
130+ test ( 'proxies beacon endpoint URLs to local server' , ( ) => {
131+ const content = html `< html >
132+ < head > </ head >
133+ < body >
134+ < div data-shs-beacon-endpoint ="https://my-store.myshopify.com/api/collect "> </ div >
135+ </ body >
136+ </ html > `
137+
138+ expect ( injectCdnProxy ( content , ctx ) ) . toMatchInlineSnapshot ( `
139+ "<html>
140+ <head></head>
141+ <body>
142+ <div data-shs-beacon-endpoint=\\"/api/collect\\"></div>
143+ </body>
144+ </html>"
145+ ` )
146+ } )
147+
148+ test ( 'proxies beacon endpoint URLs with single quotes' , ( ) => {
149+ const content = `<div data-shs-beacon-endpoint='https://my-store.myshopify.com/api/collect'></div>`
150+
151+ expect ( injectCdnProxy ( content , ctx ) ) . toMatchInlineSnapshot (
152+ `"<div data-shs-beacon-endpoint='/api/collect'></div>"` ,
153+ )
154+ } )
155+
156+ test ( 'proxies multiple beacon endpoint URLs in the same content' , ( ) => {
157+ const content = html `< html >
158+ < body >
159+ < div data-shs-beacon-endpoint ="https://my-store.myshopify.com/api/collect "> </ div >
160+ < span data-shs-beacon-endpoint ="https://my-store.myshopify.com/api/collect "> </ span >
161+ </ body >
162+ </ html > `
163+
164+ expect ( injectCdnProxy ( content , ctx ) ) . toMatchInlineSnapshot ( `
165+ "<html>
166+ <body>
167+ <div data-shs-beacon-endpoint=\\"/api/collect\\"></div>
168+ <span data-shs-beacon-endpoint=\\"/api/collect\\"></span>
169+ </body>
170+ </html>"
171+ ` )
172+ } )
129173 } )
130174
131175 describe ( 'patchRenderingResponse' , ( ) => {
0 commit comments