From 00987ea8e2c011e05a08aa6f9040570111f24ea5 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sat, 30 May 2015 01:42:56 +0300 Subject: [PATCH] Searching by MAC now works regardless of whether the device's MAC is lower or upper case. --- config/parameters-sample.json | 8 ++++---- lib/normalize.coffee | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/parameters-sample.json b/config/parameters-sample.json index ad20b68..2255fa9 100644 --- a/config/parameters-sample.json +++ b/config/parameters-sample.json @@ -11,13 +11,13 @@ "Device.DeviceInfo.HardwareVersion" : {"alias" : "summary.hardwareVersion"}, "Device.DeviceInfo.SoftwareVersion" : {"alias" : "summary.softwareVersion"}, - "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac"}, + "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"}, "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"}, - "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac"}, + "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"}, "InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"}, - "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac"}, + "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"}, "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"}, - "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac"}, + "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"}, "Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"}, "InternetGatewayDevice.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.SSID" : {"alias" : "summary.wlanSsid"}, diff --git a/lib/normalize.coffee b/lib/normalize.coffee index 290a4b4..48bad3a 100644 --- a/lib/normalize.coffee +++ b/lib/normalize.coffee @@ -27,7 +27,7 @@ common = require './common' parameters = require './parameters' -stringToRegexp = (input) -> +stringToRegexp = (input, flags) -> if (input.indexOf('*') == -1) return false @@ -44,7 +44,7 @@ stringToRegexp = (input) -> output = output.replace(/[\*]/, '.*') - return new RegExp(output) + return new RegExp(output, flags) normalizers = {} @@ -117,14 +117,14 @@ normalizers.mac = (input, normType) -> if input.indexOf('*') != -1 input = (colonizeMac(a) for a in input.split('*')).join('*') - return stringToRegexp(input, false) + return stringToRegexp(input, 'i') input = colonizeMac(input) if input.length == 17 - return input + return [input, input.toLowerCase()] - return {'$regex' : new RegExp(input)} + return {'$regex' : new RegExp(input, 'i')} exports.normalize = (path, value, normType) ->