}
if (isset($_POST['customURL']) && \is_array($_POST['customURL'])) {
- $this->customURL = \array_map('mb_strtolower', ArrayUtil::trim($_POST['customURL']));
+ $this->customURL = \array_map($this->normalizeCustomUrl(...), ArrayUtil::trim($_POST['customURL']));
}
if (isset($_POST['title']) && \is_array($_POST['title'])) {
$this->title = ArrayUtil::trim($_POST['title']);
}
}
+ /**
+ * Replaces consecutive slashes with a single slash and trims any leading
+ * or trailing slashes.
+ *
+ * @since 6.0
+ */
+ protected function normalizeCustomUrl(string $customUrl): string
+ {
+ $customUrl = \mb_strtolower($customUrl);
+ $customUrl = \preg_replace('~/{2,}~', '/', $customUrl);
+
+ return \trim($customUrl, '/');
+ }
+
/**
* Validates page title.
*