Skip to content

Commit 5f5e349

Browse files
committed
Fixed tests
1 parent cb75965 commit 5f5e349

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/helpers/Html.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,12 @@ public static function id(string $id = ''): string
737737
return $id;
738738
}
739739

740+
// remove any non-alphanumeric characters that are already preceded/followed by a hyphen
741+
$id = preg_replace('/(?<=-)[^A-Za-z0-9_.-]+|[^A-Za-z0-9_.-]+(?=-)/', '', $id);
742+
743+
// convert any remaining consecutive non-alphanumeric characters to hyphens
740744
$id = trim(preg_replace('/[^A-Za-z0-9_.-]+/', '-', $id), '-');
745+
741746
return $id ?: StringHelper::randomString(10);
742747
}
743748

0 commit comments

Comments
 (0)