From b0aa1b2af28bf573ba27c07793f45d3c54512c25 Mon Sep 17 00:00:00 2001 From: birarda Date: Tue, 20 Nov 2018 11:54:57 -0800 Subject: [PATCH] make domain settings maps keyed case insensitively --- .../resources/web/js/base-settings.js | 8 +++-- domain-server/src/DomainServer.cpp | 34 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/domain-server/resources/web/js/base-settings.js b/domain-server/resources/web/js/base-settings.js index fd404aff201..bd96f636a8b 100644 --- a/domain-server/resources/web/js/base-settings.js +++ b/domain-server/resources/web/js/base-settings.js @@ -364,7 +364,7 @@ function validateInputs() { if (keyVal.length === 0) { empty = true - markParentRowInvalid(input); + markParentRowInvalid(input) return; } @@ -373,11 +373,13 @@ function validateInputs() { _.each(otherKeys, function(otherKeyCell) { var keyInput = $(otherKeyCell).children('input'); + var lowerNewValue = keyVal.toLowerCase(); + if (keyInput.length) { - if ($(keyInput).val() == keyVal) { + if ($(keyInput).val().toLowerCase() == lowerNewValue) { duplicateKey = true; } - } else if ($(otherKeyCell).html() == keyVal) { + } else if ($(otherKeyCell).html().toLowerCase() == lowerNewValue) { duplicateKey = true; } diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 69f16af8b35..258038b8f18 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -3172,23 +3172,33 @@ void DomainServer::processPathQueryPacket(QSharedPointer messag const QString PATH_VIEWPOINT_KEY = "viewpoint"; const QString INDEX_PATH = "/"; + QString responseViewpoint; + // check out paths in the _configMap to see if we have a match - auto keypath = QString(PATHS_SETTINGS_KEYPATH_FORMAT).arg(SETTINGS_PATHS_KEY).arg(pathQuery); - QVariant pathMatch = _settingsManager.valueForKeyPath(keypath); + auto pathsVariant = _settingsManager.valueForKeyPath(SETTINGS_PATHS_KEY); - if (pathMatch.isValid() || pathQuery == INDEX_PATH) { - // we got a match, respond with the resulting viewpoint - auto nodeList = DependencyManager::get(); + auto lowerPathQuery = pathQuery.toLower(); - QString responseViewpoint; + if (pathsVariant.canConvert()) { + auto pathsMap = pathsVariant.toMap(); - // if we didn't match the path BUT this is for the index path then send back our default - if (pathMatch.isValid()) { - responseViewpoint = pathMatch.toMap()[PATH_VIEWPOINT_KEY].toString(); - } else { - const QString DEFAULT_INDEX_PATH = "/0,0,0/0,0,0,1"; - responseViewpoint = DEFAULT_INDEX_PATH; + // enumerate the paths and look case-insensitively for a matching one + for (auto it = pathsMap.constKeyValueBegin(); it != pathsMap.constKeyValueEnd(); ++it) { + if ((*it).first.toLower() == lowerPathQuery) { + responseViewpoint = (*it).second.toMap()[PATH_VIEWPOINT_KEY].toString().toLower(); + break; + } } + } + + if (responseViewpoint.isEmpty() && pathQuery == INDEX_PATH) { + const QString DEFAULT_INDEX_PATH = "/0,0,0/0,0,0,1"; + responseViewpoint = DEFAULT_INDEX_PATH; + } + + if (!responseViewpoint.isEmpty()) { + // we got a match, respond with the resulting viewpoint + auto nodeList = DependencyManager::get(); if (!responseViewpoint.isEmpty()) { QByteArray viewpointUTF8 = responseViewpoint.toUtf8();