File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,19 +176,6 @@ public function dateModified(): ?CarbonInterface
176176
177177 public function url (): string
178178 {
179- return $ this ->stripQueryString ($ this ->url );
180- }
181-
182- protected function stripQueryString (string $ url ): string
183- {
184- $ parsed = parse_url ($ url );
185-
186- $ scheme = isset ($ parsed ['scheme ' ]) ? $ parsed ['scheme ' ].':// ' : '' ;
187- $ host = $ parsed ['host ' ] ?? '' ;
188- $ port = isset ($ parsed ['port ' ]) ? ': ' .$ parsed ['port ' ] : '' ;
189- $ path = $ parsed ['path ' ] ?? '' ;
190- $ fragment = isset ($ parsed ['fragment ' ]) ? '# ' .$ parsed ['fragment ' ] : '' ;
191-
192- return $ scheme .$ host .$ port .$ path .$ fragment ;
179+ return $ this ->url ;
193180 }
194181}
Original file line number Diff line number Diff line change 5656 expect ($ subsectionContent ['anchor ' ])->toBe ('subsection ' ); // Inherits from h3
5757});
5858
59- it ('strips query strings from the url ' , function () {
60- $ indexer = new DefaultIndexer (
61- 'https://example.com/post?utm_source=newsletter&utm_medium=email ' ,
62- CrawlResponse::fake (body: view ('test::page ' ))
63- );
64-
65- expect ($ indexer ->url ())->toEqual ('https://example.com/post ' );
66- });
67-
68- it ('preserves fragments when stripping query strings ' , function () {
69- $ indexer = new DefaultIndexer (
70- 'https://example.com/post?utm_source=newsletter#section ' ,
71- CrawlResponse::fake (body: view ('test::page ' ))
72- );
73-
74- expect ($ indexer ->url ())->toEqual ('https://example.com/post#section ' );
75- });
76-
77- it ('returns url unchanged when there is no query string ' , function () {
78- $ indexer = new DefaultIndexer (
79- 'https://example.com/post ' ,
80- CrawlResponse::fake (body: view ('test::page ' ))
81- );
82-
83- expect ($ indexer ->url ())->toEqual ('https://example.com/post ' );
84- });
85-
8659it ('handles headings without id attributes ' , function () {
8760 $ indexer = new DefaultIndexer (
8861 'https://example.com ' ,
Original file line number Diff line number Diff line change 1717
1818 $ response = CrawlResponse::fake (status: 200 , body: '<html><body>test</body></html> ' );
1919
20- $ indexer = $ profile ->useIndexer ('https://example.com/post?utm_source=newsletter ' , $ response );
20+ $ indexer = $ profile ->useIndexer ('https://example.com/post?utm_source=newsletter&utm_medium=email ' , $ response );
21+
22+ expect ($ indexer ->url ())->toEqual ('https://example.com/post ' );
23+ });
24+
25+ it ('preserves fragments when normalizing urls ' , function () {
26+ $ profile = new DefaultSearchProfile ;
27+
28+ $ response = CrawlResponse::fake (status: 200 , body: '<html><body>test</body></html> ' );
29+
30+ $ indexer = $ profile ->useIndexer ('https://example.com/post?utm_source=newsletter#section ' , $ response );
31+
32+ expect ($ indexer ->url ())->toEqual ('https://example.com/post#section ' );
33+ });
34+
35+ it ('leaves urls without query strings unchanged ' , function () {
36+ $ profile = new DefaultSearchProfile ;
37+
38+ $ response = CrawlResponse::fake (status: 200 , body: '<html><body>test</body></html> ' );
39+
40+ $ indexer = $ profile ->useIndexer ('https://example.com/post ' , $ response );
2141
2242 expect ($ indexer ->url ())->toEqual ('https://example.com/post ' );
2343});
You can’t perform that action at this time.
0 commit comments