Skip to content

Commit

Permalink
fix bug in getLangUrl after moving code under src/
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Aug 21, 2024
1 parent d39500c commit 9bdb894
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function getRequestUri()
*/
public function getLangUrl($newlang=null)
{
$script_name = str_replace('/index.php', '', $this->getServerConstant('SCRIPT_NAME'));
$script_name = str_replace('/src/index.php', '', $this->getServerConstant('SCRIPT_NAME'));
$langurl = substr(str_replace($script_name, '', strval($this->getServerConstant('REQUEST_URI'))), 1);
if ($newlang !== null) {
$langurl = preg_replace("#^(.*/)?{$this->lang}/#", "$1{$newlang}/", $langurl);
Expand Down
14 changes: 7 additions & 7 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function testGetVersion()
*/
public function testGetLangUrlNoParamRoot()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/en/');
$langurl = $this->request->getLangUrl();
$this->assertEquals("en/", $langurl);
Expand All @@ -190,7 +190,7 @@ public function testGetLangUrlNoParamRoot()
*/
public function testGetLangUrlNoParamVocab()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/myvocab/en/');
$langurl = $this->request->getLangUrl();
$this->assertEquals("myvocab/en/", $langurl);
Expand All @@ -201,7 +201,7 @@ public function testGetLangUrlNoParamVocab()
*/
public function testGetLangUrlNoParamVocabIndex()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/myvocab/en/index');
$langurl = $this->request->getLangUrl();
$this->assertEquals("myvocab/en/index", $langurl);
Expand All @@ -212,7 +212,7 @@ public function testGetLangUrlNoParamVocabIndex()
*/
public function testGetLangUrlNewLangRoot()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/en/');
$this->request->setLang('en');
$langurl = $this->request->getLangUrl("sv");
Expand All @@ -224,7 +224,7 @@ public function testGetLangUrlNewLangRoot()
*/
public function testGetLangUrlNewLangVocab()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/myvocab/en/');
$this->request->setLang('en');
$langurl = $this->request->getLangUrl("sv");
Expand All @@ -236,7 +236,7 @@ public function testGetLangUrlNewLangVocab()
*/
public function testGetLangUrlNewLangVocabIndex()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/myvocab/en/index');
$this->request->setLang('en');
$langurl = $this->request->getLangUrl("sv");
Expand All @@ -248,7 +248,7 @@ public function testGetLangUrlNewLangVocabIndex()
*/
public function testGetLangUrlSanitizeSpecialChars()
{
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/index.php');
$this->request->setServerConstant('SCRIPT_NAME', '/Skosmos/src/index.php');
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/http://example.com');
$this->request->setLang('en');
$langurl = $this->request->getLangUrl();
Expand Down

0 comments on commit 9bdb894

Please sign in to comment.