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
pull/4163/head
DarkAEther 2020-08-06 03:28:44 +05:30 committed by GitHub
parent 82064152ec
commit 7aaf9d0eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

View File

@ -30,7 +30,7 @@
<div class="form-group">
<label for="registry_url" class="col-sm-3 col-lg-2 control-label text-left">
Registry URL
<portainer-tooltip position="bottom" message="URL or IP address of a Docker registry. Any protocol will be stripped."></portainer-tooltip>
<portainer-tooltip position="bottom" message="URL or IP address of a Docker registry. Any protocol and trailing slash will be stripped if present."></portainer-tooltip>
</label>
<div class="col-sm-9 col-lg-10">
<input type="text" class="form-control" id="registry_url" name="registry_url" ng-model="$ctrl.model.URL" placeholder="10.0.0.10:5000 or myregistry.domain.tld" required />

View File

@ -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;

View File

@ -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;
};

View File

@ -22,7 +22,10 @@
<div class="form-group">
<label for="registry_url" class="col-sm-3 col-lg-2 control-label text-left">
Registry URL
<portainer-tooltip position="bottom" message="URL or IP address of a Docker registry."></portainer-tooltip>
<portainer-tooltip
position="bottom"
message="URL or IP address of a Docker registry. Any protocol or trailing slash will be stripped if present."
></portainer-tooltip>
</label>
<div class="col-sm-9 col-lg-10">
<input type="text" class="form-control" id="registry_url" ng-model="registry.URL" placeholder="e.g. 10.0.0.10:5000 or myregistry.domain.tld" />