Skip to content

Commit

Permalink
fix get the referer host
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed May 25, 2024
1 parent 2046af5 commit f6f7515
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/Services/VisitorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function getRefererHost(?string $value): ?string
}

$referer = SpatieUrl::fromString($value);
$path = $referer->getPath();

return str_replace($path, '', $value);
return $referer->getScheme().'://'.$referer->getHost();
}
}
4 changes: 4 additions & 0 deletions tests/Unit/Services/VisitorServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ public function getRefererHost(): void
'https://github.com',
$this->visitorService->getRefererHost('https://github.com/laravel')
);
$this->assertSame(
'http://urlhub.test',
$this->visitorService->getRefererHost('http://urlhub.test/admin?page=2')
);
}
}

0 comments on commit f6f7515

Please sign in to comment.