[MTM] Fix relative Location header when Micropub creates an article #135
2 changed files with 3 additions and 1 deletions
Fix relative Location header when Micropub creates an article
EntryHandler used Article::link, which is deliberately a site-relative path elsewhere in the app, directly as the Micropub response's Location URL. Every other post type it returns (notes, bookmarks, places) already prepends the site URL, so articles were the only case where clients received a relative Location - iA Writer appears to treat that as a local file path and fails to open it after posting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017USyUg8PwuoDcHP8pv5xjy
commit
77998a963e
|
|
@ -37,7 +37,7 @@ class EntryHandler implements MicropubHandlerInterface
|
||||||
$location = match (true) {
|
$location = match (true) {
|
||||||
isset($dataArray['like-of']) => resolve(LikeService::class)->create($dataArray)->url,
|
isset($dataArray['like-of']) => resolve(LikeService::class)->create($dataArray)->url,
|
||||||
isset($dataArray['bookmark-of']) => resolve(BookmarkService::class)->create($dataArray)->uri,
|
isset($dataArray['bookmark-of']) => resolve(BookmarkService::class)->create($dataArray)->uri,
|
||||||
isset($dataArray['name']) => resolve(ArticleService::class)->create($dataArray)->link,
|
isset($dataArray['name']) => config('app.url').resolve(ArticleService::class)->create($dataArray)->link,
|
||||||
default => resolve(NoteService::class)->create($dataArray)->uri,
|
default => resolve(NoteService::class)->create($dataArray)->uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -871,6 +871,8 @@ class MicropubControllerTest extends TestCase
|
||||||
'main' => $content,
|
'main' => $content,
|
||||||
'published' => true,
|
'published' => true,
|
||||||
]);
|
]);
|
||||||
|
$response->assertHeader('Location');
|
||||||
|
$this->assertStringStartsWith(config('app.url').'/blog/', $response->headers->get('Location'));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue