open-nomad/ui/app/serializers/network.js
Buck Doyle 34603b8bdf
UI: Add IPv6 bracket-wrapping to network serializer (#6007)
This addresses the issue raised by @pznamensky in #5966.
2019-07-30 16:58:01 -05:00

21 lines
352 B
JavaScript

import ApplicationSerializer from './application';
import isIp from 'is-ip';
export default ApplicationSerializer.extend({
attrs: {
cidr: 'CIDR',
ip: 'IP',
mbits: 'MBits',
},
normalize(typeHash, hash) {
const ip = hash.IP;
if (isIp.v6(ip)) {
hash.IP = `[${ip}]`;
}
return this._super(...arguments);
},
});