@@ -120,6 +120,60 @@ public function invalidating_a_url_will_invalidate_all_query_string_versions_too
120120 $ this ->assertNotNull ($ cache ->get ('static-cache:responses:two ' ));
121121 }
122122
123+ #[Test]
124+ public function invalidating_a_url_with_explicit_domain_updates_correct_url_index ()
125+ {
126+ $ cache = app (Repository::class);
127+ $ cacher = new ApplicationCacher ($ cache , ['base_url ' => 'http://example.com ' ]);
128+
129+ // Different domain than base_url
130+ $ domainHash = md5 ('http://differentexample.com ' );
131+ $ cache ->forever ("static-cache: {$ domainHash }.urls " , [
132+ 'one ' => '/one ' ,
133+ 'two ' => '/two ' ,
134+ ]);
135+ $ cache ->forever ('static-cache:responses:one ' , 'html content ' );
136+ $ cache ->forever ('static-cache:responses:two ' , 'two html content ' );
137+
138+ // Invalidate explicit domain
139+ $ cacher ->invalidateUrl ('/one ' , 'http://differentexample.com ' );
140+
141+ // URL index under http://differentexample.com should be updated and not http://example.com
142+ $ this ->assertEquals (
143+ ['two ' => '/two ' ],
144+ $ cacher ->getUrls ('http://differentexample.com ' )->all ()
145+ );
146+ $ this ->assertNull ($ cache ->get ('static-cache:responses:one ' ));
147+ $ this ->assertNotNull ($ cache ->get ('static-cache:responses:two ' ));
148+ }
149+
150+ #[Test]
151+ public function invalidating_a_full_url_without_domain_extracts_domain_correctly ()
152+ {
153+ $ cache = app (Repository::class);
154+ $ cacher = new ApplicationCacher ($ cache , ['base_url ' => 'http://example.com ' ]);
155+
156+ // Different domain than base_url
157+ $ domainHash = md5 ('http://differentexample.com ' );
158+ $ cache ->forever ("static-cache: {$ domainHash }.urls " , [
159+ 'one ' => '/one ' ,
160+ 'two ' => '/two ' ,
161+ ]);
162+ $ cache ->forever ('static-cache:responses:one ' , 'html content ' );
163+ $ cache ->forever ('static-cache:responses:two ' , 'two html content ' );
164+
165+ // Invalidate full URL with no explicit domain to simulate CLI
166+ $ cacher ->invalidateUrl ('http://differentexample.com/one ' );
167+
168+ // Should extract domain from URL and update correct URL index
169+ $ this ->assertEquals (
170+ ['two ' => '/two ' ],
171+ $ cacher ->getUrls ('http://differentexample.com ' )->all ()
172+ );
173+ $ this ->assertNull ($ cache ->get ('static-cache:responses:one ' ));
174+ $ this ->assertNotNull ($ cache ->get ('static-cache:responses:two ' ));
175+ }
176+
123177 #[Test]
124178 #[DataProvider('invalidateEventProvider ' )]
125179 public function invalidating_a_url_dispatches_event ($ domain , $ expectedUrl )
0 commit comments