Commas in alias filter

Hello,
I’m using a provision script to configure several instances of a hotspot service called CoovaChilli. There is a parameter that takes comma separeted values and I don’t know how to put that in the alias filter of the declare statement. Here is what i got:

function addNewProfile(profile) { return declare(path + `[` + `Disable:,` + `Net:${profile.net},`+ `UAMListen:${profile.uam_listen},`+ `UAMServer:${profile.uam_server},`+ `UAMAllowed:\'${profile.uam_allowed}\',`+ `UAMDomain:${profile.uam_domain},`+ `SSID:${profile.ssid}`+ `]`, {path:Date.now()}, {path:1}); }

The problem is that profile.uam_allowed looks something like 8.8.8.8,4.2.2.2 and the declare function reads it as if I’m stating a new parameter. I have tried escaping it with backslash and putting it in single quotes but no success. I’d really appreciate any suggestion.

Hi, just use double quotes … plus, I personally avoid string concatenation and use string templates, so you can rewrite the code like this:

function addNewProfile(profile) { 
return declare(`${path}[Disable:,Net:"${profile.net}",UAMListen:"${profile.uam_listen}",UAMServer:"${profile.uam_server}",UAMAllowed:"${profile.uam_allowed}",UAMDomain:"${profile.uam_domain}",SSID:"${profile.ssid}"]`, {path:Date.now()}, {path:1}); 
}
2 Likes

Thank you very much. It worked perfectly.