-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config URLs: Clarify purpose and trailing slash #91
base: main
Are you sure you want to change the base?
Conversation
…RL in CollaboraDiscoveryFetcher.
@@ -90,6 +90,8 @@ protected function getDiscoveryUrl(): string { | |||
throw new CollaboraNotAvailableException('The configured Collabora Online server address is empty.'); | |||
} | |||
$wopi_client_server = trim($wopi_client_server); | |||
// The trailing slash in the configured URL is optional. | |||
$wopi_client_server = rtrim($wopi_client_server, '/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, a URL with double slash like http://example.com//hello
still works.
But explicitly calling rtrim(*, '/')
here clarifies the format we expect to find in the config value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add tests to verify that it works with and without trailing slash, but I don't really want to.
TBD.
147697c
to
d86ee71
Compare
d86ee71
to
e088d5f
Compare
// Test urls without trailing slash. | ||
$assert_session->fieldExists('Collabora Online server URL') | ||
->setValue('https://collabora.example.com'); | ||
$assert_session->fieldExists('WOPI host URL') | ||
->setValue('https://drupal.example.com'); | ||
$assert_session->buttonExists('Save configuration')->press(); | ||
$assert_session->statusMessageContains('The configuration options have been saved.', 'status'); | ||
\Drupal::configFactory()->reset(); | ||
$settings = $this->config('collabora_online.settings')->get('cool'); | ||
$this->assertSame('https://collabora.example.com', $settings['server']); | ||
$this->assertSame('https://drupal.example.com', $settings['wopi_base']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test is that much important.
I would remove it, but if we keep it, we should change the comment with "Test that the configuration accepts URLs without trailing slash."
But it would be more interesting testing that the system executes the correct request to a valid discovery url regardless of slash or not.
No description provided.