26 lines
488 B
JavaScript
26 lines
488 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import ApplicationSerializer from './application';
|
|
import isIp from 'is-ip';
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
@classic
|
|
export default class PortSerializer extends ApplicationSerializer {
|
|
attrs = {
|
|
hostIp: 'HostIP',
|
|
};
|
|
|
|
normalize(typeHash, hash) {
|
|
const ip = hash.HostIP;
|
|
|
|
if (isIp.v6(ip)) {
|
|
hash.HostIP = `[${ip}]`;
|
|
}
|
|
|
|
return super.normalize(...arguments);
|
|
}
|
|
}
|