[registryUI] pretty print the registry url

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
This commit is contained in:
Jakob Ackermann 2019-09-02 20:33:57 +02:00
parent 65bbac3453
commit b6144ae13f
No known key found for this signature in database
GPG Key ID: 17FA08AA7E62A231
6 changed files with 21 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ var registryUI = {}
registryUI.URL_QUERY_PARAM_REGEX = /[&?]url=/;
registryUI.URL_PARAM_REGEX = /^url=/;
registryUI.name = registryUI.url = function(byPassQueryParam) {
registryUI.url = function(byPassQueryParam) {
if (!registryUI._url) {
const url = registryUI.getUrlQueryParam();
if (url) {
@ -33,6 +33,9 @@ registryUI.name = registryUI.url = function(byPassQueryParam) {
}
return registryUI._url;
}
registryUI.name = function() {
return registryUI.stripHttps(registryUI.url());
}
registryUI.getRegistryServer = function(i) {
try {
const res = JSON.parse(localStorage.getItem('registryServer'));

View File

@ -24,7 +24,12 @@ registryUI.url = function() {
return url;
};
registryUI.name = function() {
return '${REGISTRY_TITLE}' || registryUI.url();
const name = '${REGISTRY_TITLE}';
if (name) {
// the user can strip the http prefix if they wish
return name;
}
return registryUI.stripHttps(registryUI.url());
};
registryUI.pullUrl = '${PULL_URL}';
registryUI.isImageRemoveActivated = true;

View File

@ -111,4 +111,11 @@ registryUI.updateQueryString = function(qs) {
}
}
history.pushState(null, '', search + window.location.hash);
}
}
registryUI.stripHttps = function (url) {
if (!url) {
return '';
}
return url.replace(/^https?:\/\//, '');
};

View File

@ -94,10 +94,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
};
registryUI.cleanName = function() {
const url = registryUI.pullUrl || (registryUI.url() && registryUI.url().length > 0 && registryUI.url()) || window.location.host;
if (url) {
return url.startsWith('http') ? url.replace(/https?:\/\//, '') : url;
}
return '';
return registryUI.stripHttps(url);
};
route.parser(null, function(path, filter) {
const f = filter