Skip to content

Commit

Permalink
[5.x] Fix wrong url on the link mark node in bard fieldtype (#11207)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
christophstockinger and jasonvarga authored Dec 4, 2024
1 parent 5bc33bf commit be8113d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Fieldtypes/Bard/LinkMark.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ protected function convertHref($href)
return '';
}

if ($item instanceof Entry) {
if (! $this->isApi() && $item instanceof Entry) {
return ($item->in(Site::current()->handle()) ?? $item)->url();
}

return $item->url();
}

private function isApi()
{
$isRestApi = config('statamic.api.enabled', false) && Str::startsWith(request()->path(), config('statamic.api.route', 'api'));
$isGraphqlApi = config('statamic.graphql.enabled', false) && Str::startsWith(request()->path(), 'graphql');

return $isRestApi || $isGraphqlApi;
}
}

0 comments on commit be8113d

Please sign in to comment.