Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/win32.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ connectionStateMap =
disconnected: "disconnected" # Win32 & Linux
associating: "connecting" # Win32

#
# urlify: Removes special chars from the given string
#
urlify = (a) ->
a.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '-').replace /^-+|-+$/g, ''

#
# win32WirelessProfileBuilder: This method generates the Windows wireless profile
# XML file corresponding to the ssid, security, and
Expand Down Expand Up @@ -182,7 +188,7 @@ module.exports =
# (3) Write xmlContent to XML wireless profile file.
#
try
fs.writeFileSync "#{_ap.ssid}.xml", xmlContent
fs.writeFileSync urlify(_ap.ssid) + ".xml", xmlContent
catch error
_msg = "Encountered an error connecting to AP: #{error}"
@WiFiLog _msg, true
Expand All @@ -195,7 +201,7 @@ module.exports =
# (4) Load new XML profile, and connect to SSID.
#
COMMANDS =
loadProfile: "netsh #{@WiFiControlSettings.iface} add profile filename=\"#{_ap.ssid}.xml\""
loadProfile: "netsh #{@WiFiControlSettings.iface} add profile filename=\"" + urlify(_ap.ssid) + ".xml\""
connect: "netsh #{@WiFiControlSettings.iface} connect ssid=\"#{_ap.ssid}\" name=\"#{_ap.ssid}\""
connectToAPChain = [ "loadProfile", "connect" ]

Expand All @@ -218,7 +224,7 @@ module.exports =
@WiFiLog "Success!"

@WiFiLog "Removing temporary WiFi config file..."
@execSync "del \".\\#{_ap.ssid}.xml\""
@execSync "del \".\\" + urlify(_ap.ssid) + ".xml\""

#
# In Windows, we are just disconnecting from the current network.
Expand Down