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

fix: remove last slash in url #170

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.4.4 - 2023-12-xx]

### Fixed

- invalid default Nextcloud URL, incorrect url with slash at the end processing. #169

## [1.4.3 - 2023-12-18]

### Added
Expand Down
11 changes: 9 additions & 2 deletions lib/Command/Daemon/ListDaemons.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln('Registered ExApp daemon configs:');
$table = new Table($output);
$table->setHeaders(['Default', 'Name', 'Display name', 'Accepts Deploy ID', 'Protocol', 'Host']);
$table->setHeaders(['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url']);
$rows = [];

foreach ($daemonConfigs as $daemon) {
$rows[] = [$daemon->getName() === $defaultDaemonName ? '*' : '', $daemon->getName(), $daemon->getDisplayName(), $daemon->getAcceptsDeployId(), $daemon->getProtocol(), $daemon->getHost()];
$rows[] = [
$daemon->getName() === $defaultDaemonName ? '*' : '',
$daemon->getName(), $daemon->getDisplayName(),
$daemon->getAcceptsDeployId(),
$daemon->getProtocol(),
$daemon->getHost(),
$daemon->getDeployConfig()['nextcloud_url']
];
}

$table->setRows($rows);
Expand Down
1 change: 1 addition & 0 deletions lib/Service/DaemonConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function registerDaemonConfig(array $params): ?DaemonConfig {
return null;
}
}
$params['deploy_config']['nextcloud_url'] = rtrim($params['deploy_config']['nextcloud_url'], '/');
try {
$daemonConfig = $this->mapper->insert(new DaemonConfig([
'name' => $params['name'],
Expand Down
3 changes: 2 additions & 1 deletion src/components/DaemonConfig/RegisterDaemonConfigModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export default {
protocol: 'unix-socket',
protocols: ['unix-socket', 'http', 'https'],
host: '/var/run/docker.sock',
nextcloud_url: window.location.origin + generateUrl(''),
// replace last slash with empty string
nextcloud_url: window.location.origin + generateUrl('').slice(0, -1),
deployConfigSettingsOpened: false,
deployConfig: {
net: 'host',
Expand Down
29 changes: 26 additions & 3 deletions tests/test_occ_commands_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
)


def register_daemon():
def register_daemon(nextcloud_url: str):
run(
"php occ app_api:daemon:register docker_local_sock "
"Docker docker-install unix-socket /var/run/docker.sock http://127.0.0.1:8080/index.php".split(),
f"Docker docker-install unix-socket /var/run/docker.sock {nextcloud_url}".split(),
stderr=DEVNULL,
stdout=DEVNULL,
check=True,
)


def unregister_daemon():
run(
"php occ app_api:daemon:unregister docker_local_sock".split(),
stderr=DEVNULL,
stdout=DEVNULL,
check=True,
Expand All @@ -32,7 +41,21 @@ def deploy_register():


if __name__ == "__main__":
register_daemon()
# nextcloud_url should be without slash at the end
register_daemon("http://127.0.0.1:8080/")
r = run("php occ app_api:daemon:list".split(), stdout=PIPE, stderr=PIPE, check=True)
assert not r.stderr.decode("UTF-8")
r_output = r.stdout.decode("UTF-8")
assert r_output.find("http://127.0.0.1:8080/") == -1
assert r_output.find("http://127.0.0.1:8080") != -1
unregister_daemon()
# nextcloud_url should be without slash at the end but with "index.php"
register_daemon("http://127.0.0.1:8080/index.php/")
r = run("php occ app_api:daemon:list".split(), stdout=PIPE, stderr=PIPE, check=True)
assert not r.stderr.decode("UTF-8")
r_output = r.stdout.decode("UTF-8")
assert r_output.find("http://127.0.0.1:8080/index.php/") == -1
assert r_output.find("http://127.0.0.1:8080/index.php") != -1
# silent should not fail, as there are not such ExApp
r = run("php occ app_api:app:unregister skeleton --silent".split(), stdout=PIPE, stderr=PIPE, check=True)
assert not r.stderr.decode("UTF-8")
Expand Down
Loading