Skip to content

Commit

Permalink
Merge pull request #6 from stnby/fix-prepareallowedips
Browse files Browse the repository at this point in the history
Fix allowed_ips and networks splitting by comma
  • Loading branch information
suquant authored Mar 18, 2022
2 parents 24238b0 + 6ceffa7 commit 6bf2576
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Modal/components/device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class DeviceModal extends Vue {
})
if(Object.keys(savedItem).includes('networks')) {
savedItem.networks = savedItem.networks.split(',')
savedItem.networks = savedItem.networks.replace(/\s+/g, '').split(',').filter(Boolean)
}
await deviceApi.createDevice(savedItem)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/components/peer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class DeviceModal extends Vue {
const newPeer = {
...newPeerData,
allowed_ips: Object.keys(newPeerData).includes('allowed_ips') ? newPeerData.allowed_ips.split(',') : null
allowed_ips: Object.keys(newPeerData).includes('allowed_ips') ? newPeerData.allowed_ips.replace(/\s+/g, '').split(',').filter(Boolean) : null
}
await deviceApi.createDevicePeer(this.$route.params.id, newPeer)
Expand Down
5 changes: 1 addition & 4 deletions src/views/dashboard/peerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ export default class peerItem extends Vue {
}
private static prepareAllowedIps(item: string): string[] | string {
if (item.length > 0) {
return item.split(',').map((item: string) => item.replace(/\n|\r/g, ''))
}
return []
return item.replace(/\s+/g, '').split(',').filter(Boolean)
}
private async deletePeer(): Promise<void> {
Expand Down

0 comments on commit 6bf2576

Please sign in to comment.