Commit c471f0fa authored by alexpott's avatar alexpott

Issue #452244 by jhedstrom: Help text for Language domain needs to specify "no trailing slash"

parent 11999557
......@@ -188,13 +188,13 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
}
// Domain names should not contain protocol and/or ports.
foreach ($languages as $langcode => $name) {
foreach ($languages as $langcode => $language) {
$value = $form_state->getValue(array('domain', $langcode));
if (!empty($value)) {
// Ensure we have exactly one protocol when checking the hostname.
$host = 'http://' . str_replace(array('http://', 'https://'), '', $value);
if (parse_url($host, PHP_URL_HOST) != $value) {
$form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language may only contain the domain name, not a protocol and/or port.', array('%language' => $name)));
$form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => $language->getName()]));
}
}
}
......
......@@ -450,6 +450,15 @@ function testLanguageDomain() {
$this->assertText('The configuration options have been saved', 'Domain configuration is saved.');
$this->rebuildContainer();
// Try to use an invalid domain.
$edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => $base_url_host,
'domain[it]' => 'it.example.com/',
];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertRaw(t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => 'Italian']));
// Build the link we're going to test.
$link = 'it.example.com' . rtrim(base_path(), '/') . '/admin';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment