@@ -109,6 +109,72 @@ describe('Providers', () => {
109109 }
110110 } )
111111
112+ it ( 'cloudflare with app.baseURL' , ( ) => {
113+ const ctx = { options : { ...emptyContext . options , nuxt : { baseURL : '/admin/' } } } as any
114+
115+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
116+ modifiers : { width : 200 } ,
117+ baseURL : '/' ,
118+ } , ctx ) ) . toMatchObject ( { url : '/cdn-cgi/image/w=200/admin/images/test.png' } )
119+
120+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
121+ modifiers : { } ,
122+ baseURL : '/' ,
123+ } , ctx ) ) . toMatchObject ( { url : '/admin/images/test.png' } )
124+ } )
125+
126+ it ( 'cloudflare with external image' , ( ) => {
127+ expect ( cloudflare ( ) . getImage ( 'https://external.com/photo.jpg' , {
128+ modifiers : { width : 200 } ,
129+ baseURL : '/' ,
130+ } , emptyContext ) ) . toMatchObject ( { url : '/cdn-cgi/image/w=200/https://external.com/photo.jpg' } )
131+
132+ expect ( cloudflare ( ) . getImage ( 'https://external.com/photo.jpg' , {
133+ modifiers : { } ,
134+ baseURL : '/' ,
135+ } , emptyContext ) ) . toMatchObject ( { url : 'https://external.com/photo.jpg' } )
136+ } )
137+
138+ it ( 'cloudflare cross-zone' , ( ) => {
139+ const ctx = { options : { ...emptyContext . options , nuxt : { baseURL : '/' } } } as any
140+
141+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
142+ modifiers : { width : 200 } ,
143+ baseURL : 'https://abc.cz' ,
144+ } , ctx ) ) . toMatchObject ( { url : 'https://abc.cz/cdn-cgi/image/w=200/images/test.png' } )
145+
146+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
147+ modifiers : { } ,
148+ baseURL : 'https://abc.cz' ,
149+ } , ctx ) ) . toMatchObject ( { url : '/images/test.png' } )
150+ } )
151+
152+ it ( 'cloudflare cross-zone with app.baseURL' , ( ) => {
153+ const ctx = { options : { ...emptyContext . options , nuxt : { baseURL : '/admin/' } } } as any
154+
155+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
156+ modifiers : { width : 200 } ,
157+ baseURL : 'https://abc.cz' ,
158+ } , ctx ) ) . toMatchObject ( { url : 'https://abc.cz/cdn-cgi/image/w=200/admin/images/test.png' } )
159+
160+ expect ( cloudflare ( ) . getImage ( '/images/test.png' , {
161+ modifiers : { } ,
162+ baseURL : 'https://abc.cz' ,
163+ } , ctx ) ) . toMatchObject ( { url : '/admin/images/test.png' } )
164+ } )
165+
166+ it ( 'cloudflare cross-zone with external src' , ( ) => {
167+ expect ( cloudflare ( ) . getImage ( 'https://123.cz/images/test.png' , {
168+ modifiers : { width : 200 } ,
169+ baseURL : 'https://abc.cz' ,
170+ } , emptyContext ) ) . toMatchObject ( { url : 'https://abc.cz/cdn-cgi/image/w=200/https://123.cz/images/test.png' } )
171+
172+ expect ( cloudflare ( ) . getImage ( 'https://123.cz/images/test.png' , {
173+ modifiers : { } ,
174+ baseURL : 'https://abc.cz' ,
175+ } , emptyContext ) ) . toMatchObject ( { url : 'https://123.cz/images/test.png' } )
176+ } )
177+
112178 it ( 'cloudinary' , ( ) => {
113179 const providerOptions = {
114180 baseURL : '/' ,
0 commit comments