Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

donquixote
Copy link
Collaborator

No description provided.

@@ -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, '/');
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@donquixote donquixote force-pushed the config-urls-trailing-slash branch from 147697c to d86ee71 Compare January 22, 2025 17:33
@donquixote donquixote force-pushed the config-urls-trailing-slash branch from d86ee71 to e088d5f Compare January 22, 2025 17:36
@donquixote donquixote marked this pull request as ready for review January 22, 2025 17:37
Comment on lines +120 to +130
// 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']);
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants