Only direct Link redirects use destination_url; catalog QR slugs proxy through the platform resolver instead of malformed summary URLs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,7 +21,7 @@ class LinkRedirectController extends Controller
|
||||
{
|
||||
if ($path === null || $path === '') {
|
||||
$link = $this->links->resolve($request, $slug);
|
||||
if ($link !== null) {
|
||||
if ($link !== null && $link->isDirectRedirect()) {
|
||||
return redirect()->away($link->destination_url, 302);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ class ShortLink extends Model
|
||||
return $this->expires_at !== null && $this->expires_at->isPast();
|
||||
}
|
||||
|
||||
/** Simple URL redirects created in Link; QR ecosystem slugs resolve via the platform proxy. */
|
||||
public function isDirectRedirect(): bool
|
||||
{
|
||||
return $this->is_managed_here && $this->source_kind === 'redirect';
|
||||
}
|
||||
|
||||
public function sourceAppLabel(): string
|
||||
{
|
||||
return match ($this->source_app) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class LinkCatalogSyncService
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
'label' => $row['label'] ?? null,
|
||||
'destination_url' => (string) ($row['destination_url'] ?? LadillLink::url($slug)),
|
||||
'destination_url' => (string) ($row['destination_summary'] ?? $row['destination_url'] ?? LadillLink::url($slug)),
|
||||
'source_app' => (string) ($row['source_app'] ?? 'platform'),
|
||||
'source_kind' => (string) ($row['source_kind'] ?? 'qr'),
|
||||
'source_ref' => isset($row['source_ref']) ? (string) $row['source_ref'] : null,
|
||||
|
||||
@@ -24,8 +24,11 @@ class LinkPlatformProxy
|
||||
$target .= '?'.$qs;
|
||||
}
|
||||
|
||||
$client = Http::withOptions(['allow_redirects' => false])->timeout(15);
|
||||
$method = strtoupper($request->method());
|
||||
$followRedirects = $method === 'GET' || $method === 'HEAD';
|
||||
$client = Http::withOptions([
|
||||
'allow_redirects' => $followRedirects ? ['max' => 5] : false,
|
||||
])->timeout(15);
|
||||
|
||||
$pending = match ($method) {
|
||||
'POST' => $client->withHeaders($this->forwardHeaders($request))->asForm()->post($target, $request->post()),
|
||||
|
||||
Reference in New Issue
Block a user