diff --git a/config/install/redirect.domain.yml b/config/install/redirect.domain.yml
deleted file mode 100644
index e69de29..0000000
diff --git a/modules/redirect_domain/config/install/redirect_domain.domains.yml b/modules/redirect_domain/config/install/redirect_domain.domains.yml
new file mode 100644
index 0000000..05c0310
--- /dev/null
+++ b/modules/redirect_domain/config/install/redirect_domain.domains.yml
@@ -0,0 +1 @@
+domain_redirects: { }
diff --git a/modules/redirect_domain/redirect_domain.module b/modules/redirect_domain/redirect_domain.module
new file mode 100644
index 0000000..4747119
--- /dev/null
+++ b/modules/redirect_domain/redirect_domain.module
@@ -0,0 +1,20 @@
+' . t('About') . '';
+ $output .= '
' . t('The Redirect domain module allows users to redirect between domains.') . '
';
+ $output .= '' . t('Uses') . '
';
+ $output .= '' . t('Manage domain redirects') . '';
+ $output .= '' . t('The domain redirect is accessed through Domain Redirects. The user can add the domain redirects through the domain redirect table which consists of the domain from which it needs to be redirected, the sub path and the complete url destination to which it needs to be redirected. The module also supports the usage of a wildcard redirecting, thus many requests can be handled with one instance of domain redirect.', [':domainlist' => Url::fromRoute('redirect_domain.domain_list')->toString()]) . '';
+ return $output;
+ }
+}
diff --git a/modules/redirect_domain/src/Form/RedirectDomainForm.php b/modules/redirect_domain/src/Form/RedirectDomainForm.php
index cdae1c9..5c40b68 100644
--- a/modules/redirect_domain/src/Form/RedirectDomainForm.php
+++ b/modules/redirect_domain/src/Form/RedirectDomainForm.php
@@ -150,9 +150,9 @@ class RedirectDomainForm extends ConfigFormBase {
foreach ($redirects as $redirect) {
if (!empty($redirect['from']) && !empty($redirect['destination'])) {
// Replace '.' with ':' for an eligible key.
- $redirect['from'] = str_replace('.',':',$redirect['from']);
+ $redirect['from'] = str_replace('.', ':', $redirect['from']);
$domain_redirects[$redirect['from']][] = [
- 'sub_path' => $redirect['sub_path']? : '/',
+ 'sub_path' => ltrim($redirect['sub_path'], '/') . '/',
'destination' => $redirect['destination']
];
}
diff --git a/modules/redirect_domain/src/Tests/RedirectDomainUITest.php b/modules/redirect_domain/src/Tests/RedirectDomainUITest.php
index 2af009d..a8bd463 100644
--- a/modules/redirect_domain/src/Tests/RedirectDomainUITest.php
+++ b/modules/redirect_domain/src/Tests/RedirectDomainUITest.php
@@ -40,11 +40,12 @@ class RedirectDomainUITest extends WebTestBase {
// Add another field for new domain redirect.
$this->drupalPostAjaxForm(NULL, [], ['op' => t('Add another')]);
- // Add two new domain redirects.
+ // Add two new domain redirects, one without sub path.
$edit = [
'redirects[0][from]' => 'foo.example.org',
'redirects[0][destination]' => 'www.example.org/foo',
'redirects[1][from]' => 'bar.example.org',
+ 'redirects[1][sub_path]' => '',
'redirects[1][destination]' => 'www.example.org/bar',
];
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -54,5 +55,9 @@ class RedirectDomainUITest extends WebTestBase {
$this->assertFieldByName('redirects[0][destination]', 'www.example.org/foo');
$this->assertFieldByName('redirects[1][from]', 'bar.example.org');
$this->assertFieldByName('redirects[1][destination]', 'www.example.org/bar');
+
+ // Ensure that the sub paths are correct.
+ $this->assertFieldByName('redirects[0][sub_path]', '/');
+ $this->assertFieldByName('redirects[1][sub_path]', '/');
}
}