Skip to content

Commit 89748fd

Browse files
committed
Add getUriWithoutLocale function
1 parent d928f76 commit 89748fd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/LaravelLocale/Manager.php

+18
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ public function getUriLocale()
6969
return $this->getDefaultLocale();
7070
}
7171

72+
/**
73+
* Return requested uri without locale.
74+
*
75+
* @return string
76+
*/
77+
public function getUriWithoutLocale()
78+
{
79+
$current = $this->getUriLocale();
80+
$default = $this->getDefaultLocale();
81+
$path = $this->request->path();
82+
83+
if ($current == $default) {
84+
return $path;
85+
}
86+
87+
return preg_replace('/'.$current.'\/?/', '', $path);
88+
}
89+
7290
/**
7391
* Get user's locale.
7492
*

0 commit comments

Comments
 (0)