Skip to content

Commit

Permalink
Merge pull request #97 from RonasIT/fix-pathes-for-windows
Browse files Browse the repository at this point in the history
fix: unable to generate requests at Windows
  • Loading branch information
DenTray authored Nov 27, 2023
2 parents 230d9ca + 8e8d860 commit f8ee1f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=7.4",
"laravel/framework": ">=5.4.0",
"laravel/framework": ">=5.5.0",
"guzzlehttp/guzzle": ">=6.0",
"maatwebsite/excel": "3.*",
"tecnickcom/tcpdf": "~6.2.22",
Expand Down
5 changes: 3 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Support\Collection;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

/**
* Round all values in list of floats.
Expand Down Expand Up @@ -106,11 +107,11 @@ function mkdir_recursively($path)
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
}

$path = str_replace($currentPath, '', $path);
$path = Str::replaceFirst($currentPath, '', $path);
$explodedPath = explode('/', $path);

array_walk($explodedPath, function ($dir) use (&$currentPath) {
if ($currentPath != '/') {
if ($currentPath !== '/') {
$currentPath .= '/' . $dir;
} else {
$currentPath .= $dir;
Expand Down
11 changes: 11 additions & 0 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,15 @@ public function testArrayRemoveElements()

$this->assertEqualsFixture('array_remove_elements/result.json', $result);
}

public function testMkDirRecursively()
{
mkdir_recursively('dir1/dir2/dir3');

$this->assertTrue(file_exists('dir1'));
$this->assertTrue(file_exists('dir1/dir2'));
$this->assertTrue(file_exists('dir1/dir2/dir3'));

rmdir_recursively('dir1');
}
}

0 comments on commit f8ee1f2

Please sign in to comment.