mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 11:25:41 +03:00
UI: Add IPv6 bracket-wrapping to network serializer (#6007)
This addresses the issue raised by @pznamensky in #5966.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
## 0.9.5 (Unreleased)
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
* ui: Fixed links containing IPv6 addresses to include required square brackets [[GH-6007](https://github.com/hashicorp/nomad/pull/6007)]
|
||||
|
||||
## 0.9.4 (July 30, 2019)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
import isIp from 'is-ip';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
@@ -6,4 +7,14 @@ export default ApplicationSerializer.extend({
|
||||
ip: 'IP',
|
||||
mbits: 'MBits',
|
||||
},
|
||||
|
||||
normalize(typeHash, hash) {
|
||||
const ip = hash.IP;
|
||||
|
||||
if (isIp.v6(ip)) {
|
||||
hash.IP = `[${ip}]`;
|
||||
}
|
||||
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
"flat": "^4.0.0",
|
||||
"fuse.js": "^3.4.4",
|
||||
"husky": "^1.3.1",
|
||||
"is-ip": "^3.1.0",
|
||||
"ivy-codemirror": "^2.1.0",
|
||||
"lint-staged": "^8.1.5",
|
||||
"loader.js": "^4.7.0",
|
||||
|
||||
31
ui/tests/unit/serializers/network-test.js
Normal file
31
ui/tests/unit/serializers/network-test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import NetworkModel from 'nomad-ui/models/network';
|
||||
|
||||
module('Unit | Serializer | Network', function(hooks) {
|
||||
setupTest(hooks);
|
||||
hooks.beforeEach(function() {
|
||||
this.store = this.owner.lookup('service:store');
|
||||
this.subject = () => this.store.serializerFor('network');
|
||||
});
|
||||
|
||||
test('v4 IPs are passed through', async function(assert) {
|
||||
const ip = '10.0.13.12';
|
||||
const original = {
|
||||
IP: ip,
|
||||
};
|
||||
|
||||
const { data } = this.subject().normalize(NetworkModel, original);
|
||||
assert.equal(data.attributes.ip, ip);
|
||||
});
|
||||
|
||||
test('v6 IPs are wrapped in square brackets', async function(assert) {
|
||||
const ip = '2001:0dac:aba3:0000:0000:8a2e:0370:7334';
|
||||
const original = {
|
||||
IP: ip,
|
||||
};
|
||||
|
||||
const { data } = this.subject().normalize(NetworkModel, original);
|
||||
assert.equal(data.attributes.ip, `[${ip}]`);
|
||||
});
|
||||
});
|
||||
12
ui/yarn.lock
12
ui/yarn.lock
@@ -6569,6 +6569,11 @@ invert-kv@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"
|
||||
integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY=
|
||||
|
||||
ip-regex@^4.0.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.1.0.tgz#5ad62f685a14edb421abebc2fff8db94df67b455"
|
||||
integrity sha512-pKnZpbgCTfH/1NLIlOduP/V+WRXzC2MOz3Qo8xmxk8C5GudJLgK5QyLVXOSWy3ParAH7Eemurl3xjv/WXYFvMA==
|
||||
|
||||
ipaddr.js@1.8.0:
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.8.0.tgz#eaa33d6ddd7ace8f7f6fe0c9ca0440e706738b1e"
|
||||
@@ -6719,6 +6724,13 @@ is-glob@^4.0.0:
|
||||
dependencies:
|
||||
is-extglob "^2.1.1"
|
||||
|
||||
is-ip@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-3.1.0.tgz#2ae5ddfafaf05cb8008a62093cf29734f657c5d8"
|
||||
integrity sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q==
|
||||
dependencies:
|
||||
ip-regex "^4.0.0"
|
||||
|
||||
is-number@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"
|
||||
|
||||
Reference in New Issue
Block a user