Skip to content

Commit 4e90701

Browse files
committed
composeSegments function should trim extra slash
1 parent 2879f91 commit 4e90701

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/traits/LfmHelpers.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function getThumbPath($image_name = null)
1717

1818
public function getCurrentPath($file_name = null, $is_thumb = null)
1919
{
20-
$path = $this->composeSegments('dir', $is_thumb) . $file_name;
20+
$path = $this->composeSegments('dir', $is_thumb, $file_name);
2121

2222
if ($this->isRunningOnWindows()) {
2323
$path = str_replace('/', '\\', $path);
@@ -33,17 +33,26 @@ public function getThumbUrl($image_name = null)
3333

3434
public function getFileUrl($image_name = null, $is_thumb = null)
3535
{
36-
$url = $this->composeSegments('url', $is_thumb) . $image_name;
36+
$url = $this->composeSegments('url', $is_thumb, $image_name);
3737

38-
return str_replace('\\', '/', $url);
38+
return $url;
3939
}
4040

41-
private function composeSegments($type, $is_thumb)
41+
private function composeSegments($type, $is_thumb, $file_name)
4242
{
43-
return $this->getPathPrefix($type)
43+
$full_path = $this->getPathPrefix($type)
4444
. $this->getFormatedWorkingDir()
4545
. '/'
46-
. $this->appendThumbFolderPath($is_thumb);
46+
. $this->appendThumbFolderPath($is_thumb)
47+
. $file_name;
48+
49+
$full_path = str_replace('\\', '/', $full_path);
50+
51+
if (ends_with($full_path, '/')) {
52+
$full_path = substr($full_path, 0, -1);
53+
}
54+
55+
return $full_path;
4756
}
4857

4958
private function getFormatedWorkingDir()

0 commit comments

Comments
 (0)