Skip to content

Commit

Permalink
Fixed getLocalizedURL producing duplicate query string (side effect of
Browse files Browse the repository at this point in the history
  • Loading branch information
neochief authored and Marc Cámara committed Oct 30, 2018
1 parent f79896f commit e82a6c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Mcamara/LaravelLocalization/LaravelLocalization.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public function getLocalizedURL($locale = null, $url = null, $attributes = [], $
$url = $this->request->fullUrl();
} else {
$url = $this->url->to($url);
$url = preg_replace('/'. preg_quote($urlQuery, '/') . '$/', '', $url);
}

if ($locale && $translatedRoute = $this->findTranslatedRouteByUrl($url, $attributes, $this->currentLocale)) {
Expand Down
10 changes: 10 additions & 0 deletions tests/LocalizerTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ public function testGetLocalizedURL()
app('laravellocalization')->getLocalizedURL('en', $this->test_url.'test')
);

$this->assertEquals(
$this->test_url.'test?a=1',
app('laravellocalization')->getLocalizedURL('en', $this->test_url.'test?a=1')
);

$crawler = $this->call(
'GET',
app('laravellocalization')->getLocalizedURL('en', $this->test_url.'test'),
Expand All @@ -278,6 +283,11 @@ public function testGetLocalizedURL()
$this->test_url.'es/test',
app('laravellocalization')->getLocalizedURL('es', $this->test_url.'test')
);

$this->assertEquals(
$this->test_url.'es/test?a=1',
app('laravellocalization')->getLocalizedURL('es', $this->test_url.'test?a=1')
);
}

/**
Expand Down

0 comments on commit e82a6c9

Please sign in to comment.