diff --git a/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php b/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php
index cd67afdbef5e1738792aa1a9ecb253b406f0135c..6151dce59509477ba1ba61dcbcebea23e123104b 100644
--- a/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php
@@ -215,7 +215,7 @@ class InputSlugElement extends AbstractFormElement
      */
     protected function getPrefix(SiteInterface $site, int $requestLanguageId = 0): string
     {
-        $language = $site->getLanguageById($requestLanguageId);
+        $language = ($requestLanguageId < 0) ? $site->getDefaultLanguage() : $site->getLanguageById($requestLanguageId);
         $base = $language->getBase();
         $baseUrl = (string)$base;
         $baseUrl = rtrim($baseUrl, '/');
diff --git a/typo3/sysext/backend/Tests/Unit/Form/Element/InputSlugElementTest.php b/typo3/sysext/backend/Tests/Unit/Form/Element/InputSlugElementTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..08b7d59bec0d117349a4c1e8bb6be3b2e46eea9e
--- /dev/null
+++ b/typo3/sysext/backend/Tests/Unit/Form/Element/InputSlugElementTest.php
@@ -0,0 +1,82 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Backend\Tests\Unit\Form\Element;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\Element\InputSlugElement;
+use TYPO3\CMS\Core\Site\Entity\Site;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+/**
+ * Tests for InputSlugElement Form
+ */
+class InputSlugElementTest extends UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function getPrefixReturnsDefaultBaseUrlForAllDefinedLanguagesAndMinusOne(): void
+    {
+        $languages = [
+            [
+                'languageId' => 0,
+                'locale' => 'en_US.UTF-8',
+                'base' => '/en/'
+            ],
+            [
+                'languageId' => 1,
+                'locale' => 'de_DE.UTF-8',
+                'base' => '/de/'
+            ]
+        ];
+
+        $site = new Site('www.foo.de', 0, [
+            'languages' => $languages
+        ]);
+
+        $subject = $this->getAccessibleMock(
+            InputSlugElement::class,
+            ['dummy'],
+            [],
+            '',
+            false
+        );
+
+        static::assertSame('/en', $subject->_call('getPrefix', $site, -1));
+        static::assertSame('/en', $subject->_call('getPrefix', $site, 0));
+        static::assertSame('/de', $subject->_call('getPrefix', $site, 1));
+    }
+
+    /**
+     * @test
+     */
+    public function getPrefixThrowsInvalidArgumentExceptionForUndefinedLanguages(): void
+    {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1522960188);
+
+        $site = new Site('www.foo.de', 0, []);
+
+        $subject = $this->getAccessibleMock(
+            InputSlugElement::class,
+            ['dummy'],
+            [],
+            '',
+            false
+        );
+
+        $subject->_call('getPrefix', $site, 99);
+    }
+}