Skip to content

Commit e392165

Browse files
committed
Merge branch 'develop-patch' into develop-minor
2 parents e30aa3c + 309ef90 commit e392165

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

config/components.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,21 @@
399399

400400
if ($parts[0] ?? null) {
401401
$page = $kirby->site()->find($parts[0]);
402+
403+
// get the extension of the url, if there is one, to add it back later
404+
$extension = F::extension($parts[0]);
402405
} else {
403406
$page = $kirby->site()->page();
404407
}
405408

406409
if ($page) {
407410
$path = $page->url($language);
408411

412+
// add the extension back to the url, if there was one
413+
if (isset($extension) === true && $extension !== '') {
414+
$path .= '.' . $extension;
415+
}
416+
409417
if (isset($parts[1]) === true) {
410418
$path .= '#' . $parts[1];
411419
}

tests/Cms/App/AppComponentsTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,57 @@ public function testTemplate(): void
384384
$this->assertInstanceOf(Template::class, $this->app->template('default'));
385385
}
386386

387+
public function testUrlPreservesExtensionOnMultilangSite(): void
388+
{
389+
$this->app->clone([
390+
'urls' => [
391+
'index' => 'https://getkirby.com'
392+
],
393+
'languages' => [
394+
[
395+
'code' => 'en',
396+
'name' => 'English',
397+
'default' => true,
398+
'url' => '/'
399+
],
400+
[
401+
'code' => 'de',
402+
'name' => 'Deutsch',
403+
'url' => '/de'
404+
]
405+
],
406+
'site' => [
407+
'children' => [
408+
['slug' => 'articles']
409+
]
410+
]
411+
]);
412+
413+
// extension is preserved for the default language
414+
$this->assertSame(
415+
'https://getkirby.com/articles.xml',
416+
url('articles.xml')
417+
);
418+
419+
// extension is preserved for a secondary language
420+
$this->assertSame(
421+
'https://getkirby.com/de/articles.xml',
422+
url('articles.xml', 'de')
423+
);
424+
425+
// works without extension as before
426+
$this->assertSame(
427+
'https://getkirby.com/articles',
428+
url('articles')
429+
);
430+
431+
// fragment is still appended correctly alongside the extension
432+
$this->assertSame(
433+
'https://getkirby.com/articles.xml#section',
434+
url('articles.xml#section')
435+
);
436+
}
437+
387438
public function testUrlPlugin(): void
388439
{
389440
$this->app->clone([

0 commit comments

Comments
 (0)