Skip to content

Commit be67e9e

Browse files
authored
Merge pull request #8 from AndreasElia/fix/duplicate-structured-route
Stop route creation on folder loop
2 parents 854f4da + f6bfcfe commit be67e9e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ExportPostman.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ public function handle(): void
101101
$this->info("Postman Collection Exported: $exportName");
102102
}
103103

104-
protected function ensurePath(array &$root, array $segments, array $request, string $destination): void
104+
protected function ensurePath(array &$routes, array $segments, array $request, string $destination): void
105105
{
106-
$parent = &$root;
106+
$parent = &$routes;
107107

108-
foreach ($segments as $segment) {
108+
foreach ($segments as $segmentKey => $segment) {
109109
$matched = false;
110110

111111
foreach ($parent['item'] as &$item) {
@@ -126,7 +126,7 @@ protected function ensurePath(array &$root, array $segments, array $request, str
126126
if (! $matched) {
127127
$item = [
128128
'name' => $segment,
129-
'item' => [$request],
129+
'item' => $segmentKey !== 0 ? [$request] : [],
130130
];
131131

132132
$parent['item'][] = &$item;

0 commit comments

Comments
 (0)