Issue #452244 by jhedstrom: Help text for Language domain needs to specify "no trailing slash"
parent
119995572a
commit
c471f0fa7c
|
@ -188,13 +188,13 @@ class NegotiationUrlForm extends ConfigFormBase {
|
|||
}
|
||||
|
||||
// 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 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
|
|||
$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';
|
||||
|
||||
|
|
Loading…
Reference in New Issue