Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/current/2329-allow-slash-in-recipes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Fixes

- Allow slashes in recipe names
2 changes: 1 addition & 1 deletion lib/Helper/Filter/JSON/RecipeNameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(TextCleanupHelper $textCleanupHelper) {

public function apply(array &$json): bool {
// Clean up name to prevent issues
$cleanedName = $this->textCleanupHelper->cleanUp($json['name'], true, true);
$cleanedName = $this->textCleanupHelper->cleanUp($json['name'], true, false, false);
$changed = ($json['name'] !== $cleanedName);

// Restrict length of name
Expand Down
7 changes: 5 additions & 2 deletions lib/Helper/TextCleanupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class TextCleanupHelper {
public function cleanUp(
?string $str,
bool $removeNewlines = true,
bool $removeSlashes = false
bool $removeSlashes = false,
bool $removeBackslashes = true
): string {
if (!$str) {
return '';
Expand All @@ -27,7 +28,9 @@ public function cleanUp(
}

$str = str_replace("\t", ' ', $str);
$str = str_replace("\\", '_', $str);
if($removeBackslashes) {
$str = str_replace("\\", '_', $str);
}

// We want to remove forward-slashes for the name of the recipe, to tie it to the directory structure, which cannot have slashes
if ($removeSlashes) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Helper/Filter/JSON/RecipeNameFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testCleanFilter($oldName, $retCleaning, $newName, $isChanged) {
$recipe['name'] = $oldName;

$this->textCleaner->method('cleanUp')->willReturnMap([
[$oldName, true, true, $retCleaning],
[$oldName, true, false, false, $retCleaning],
]);

$this->assertEquals($isChanged, $this->dut->apply($recipe));
Expand Down