retrieve link url from database rather than request url

increases robustness and solve issues with sloppy redirect
interpretation across browsers
This commit is contained in:
snicker 2022-09-24 11:01:09 -07:00
parent 661813b349
commit 697ed3ce19
1 changed files with 1 additions and 7 deletions

View File

@ -183,7 +183,6 @@ class UserController extends Controller
public function clickNumber(request $request) public function clickNumber(request $request)
{ {
$link = $request->link; $link = $request->link;
$query = $request->query();
$linkId = $request->id; $linkId = $request->id;
if(empty($link && $linkId)) if(empty($link && $linkId))
@ -191,13 +190,8 @@ class UserController extends Controller
return abort(404); return abort(404);
} }
if(!empty($query)) {
$qs = [];
foreach($query as $qk => $qv) { $qs[] = $qk .'='. $qv; }
$link = $link .'?'. implode('&', $qs);
}
Link::where('id', $linkId)->increment('click_number', 1); Link::where('id', $linkId)->increment('click_number', 1);
$link = Link::select('link')->where('id', $linkId)->get()[0]['link'];
return redirect()->away($link); return redirect()->away($link);
} }