diff --git a/lib/shared/addon/mixins/endpoint-ports.js b/lib/shared/addon/mixins/endpoint-ports.js index ef9223368..995bb3f31 100644 --- a/lib/shared/addon/mixins/endpoint-ports.js +++ b/lib/shared/addon/mixins/endpoint-ports.js @@ -6,7 +6,7 @@ export default Mixin.create({ displayEndpoints: function () { let parts = []; - const endpoints = (get(this, 'publicEndpoints') || []); + const endpoints = (get(this, 'publicEndpoints') || []).sort(Util.compareDisplayEndpoint); endpoints.forEach((endpoint) => { if ( !get(endpoint, 'isReady') ){ diff --git a/lib/shared/addon/utils/util.js b/lib/shared/addon/utils/util.js index 542983f8c..d1d2d6729 100644 --- a/lib/shared/addon/utils/util.js +++ b/lib/shared/addon/utils/util.js @@ -13,6 +13,46 @@ export function arrayIntersect(a, b) { }); } +export function compareDisplayEndpoint(i1, i2) { + if ( !i1 ) { + return 1; + } + + if ( !i2 ) { + return -1; + } + + const in1 = i1.displayEndpoint; + const in2 = i2.displayEndpoint; + if ( !in1 ) { + return 1; + } + + if ( !in2 ) { + return -1; + } + + if ( in1.startsWith('/') && !in2.startsWith('/') ) { + return -1; + } else if ( !in1.startsWith('/') && in2.startsWith('/') ) { + return 1; + } + + if ( in1 === '80/http' && in2 !== '80/http' ) { + return -1; + } else if ( in1 !== '80/http' && in2 === '80/http' ) { + return 1; + } + + if ( in1 === '443/https' && in2 !== '443/https' ) { + return -1; + } else if ( in1 !== '443/https' && in2 === '443/https' ) { + return 1; + } + + return in1.localeCompare(in2); +} + export function filterByValues(ary,field,values) { return ary.filter((obj) => { return values.includes(obj.get(field)); @@ -352,6 +392,7 @@ var Util = { addQueryParams: addQueryParams, arrayDiff: arrayDiff, arrayIntersect: arrayIntersect, + compareDisplayEndpoint: compareDisplayEndpoint, camelToTitle: camelToTitle, constructUrl: constructUrl, download: download,