From 7aaf9d0eb7c7d7e92686c096391af60113d643e5 Mon Sep 17 00:00:00 2001 From: DarkAEther <30438425+DarkAEther@users.noreply.github.com> Date: Thu, 6 Aug 2020 03:28:44 +0530 Subject: [PATCH] fix(registries): remove trailing slash and protocol in registry URLs (#4131) * feat(registries) prevent trailing slash * fix(registries) avoid trailing slash in update registry * fix(registries) include trailing slash removal notice in tooltips * fix(registries) remove protocol when updating existing registry * fix(registries) uniform usage of string replace function for registry update --- .../forms/registry-form-custom/registry-form-custom.html | 2 +- app/portainer/models/registry.js | 1 + app/portainer/services/api/registryService.js | 2 ++ app/portainer/views/registries/edit/registry.html | 5 ++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/portainer/components/forms/registry-form-custom/registry-form-custom.html b/app/portainer/components/forms/registry-form-custom/registry-form-custom.html index fc9f4da1e..7081aff7c 100644 --- a/app/portainer/components/forms/registry-form-custom/registry-form-custom.html +++ b/app/portainer/components/forms/registry-form-custom/registry-form-custom.html @@ -30,7 +30,7 @@
diff --git a/app/portainer/models/registry.js b/app/portainer/models/registry.js index 54bf040c2..a87bf1b1f 100644 --- a/app/portainer/models/registry.js +++ b/app/portainer/models/registry.js @@ -51,6 +51,7 @@ export function RegistryCreateRequest(model) { this.Name = model.Name; this.Type = model.Type; this.URL = _.replace(model.URL, /^https?\:\/\//i, ''); + this.URL = _.replace(this.URL, /\/$/, ''); this.Authentication = model.Authentication; if (model.Authentication) { this.Username = model.Username; diff --git a/app/portainer/services/api/registryService.js b/app/portainer/services/api/registryService.js index d1468c91e..183cfc943 100644 --- a/app/portainer/services/api/registryService.js +++ b/app/portainer/services/api/registryService.js @@ -62,6 +62,8 @@ angular.module('portainer.app').factory('RegistryService', [ }; service.updateRegistry = function (registry) { + registry.URL = _.replace(registry.URL, /^https?\:\/\//i, ''); + registry.URL = _.replace(registry.URL, /\/$/, ''); return Registries.update({ id: registry.Id }, registry).$promise; }; diff --git a/app/portainer/views/registries/edit/registry.html b/app/portainer/views/registries/edit/registry.html index 4ddcb569d..011afb5ea 100644 --- a/app/portainer/views/registries/edit/registry.html +++ b/app/portainer/views/registries/edit/registry.html @@ -22,7 +22,10 @@