Skip to content

Commit

Permalink
Regexp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Jun 10, 2016
1 parent cf3af64 commit 0dcc51c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions js/bloodhound.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ $(document).ready(function(){
' {{#type_group}}' +
' <li onclick="setLabelAsStart(\'{{label}}\')"><i class="glyphicon glyphicon-screenshot"></i> Set as Starting Node</li>' +
' <li onclick="setLabelAsEnd(\'{{label}}\')"><i class="glyphicon glyphicon-screenshot"></i> Set as Ending Node</li>' +
' <li onclick="doQuery(\'MATCH (n {name:&quot;{{label}}&quot;})<-[r:MemberOf]-m RETURN n,r,m\')"><i class="glyphicon glyphicon-screenshot"></i> Get Members</li>' +
' <li onclick="doQuery(\'MATCH (n {name:&quot;{{label}}&quot;})-[r:AdminTo]->m RETURN n,r,m\', &quot;{{label}}&quot;)"><i class="glyphicon glyphicon-screenshot"></i> Admin To</li>' +
' <li onclick="doQuery(\'MATCH (n {name:&quot;{{label}}&quot;})<-[r:MemberOf]-(m) RETURN n,r,m\')"><i class="glyphicon glyphicon-screenshot"></i> Get Members</li>' +
' <li onclick="doQuery(\'MATCH (n {name:&quot;{{label}}&quot;})-[r:AdminTo]->(m) RETURN n,r,m\', &quot;{{label}}&quot;)"><i class="glyphicon glyphicon-screenshot"></i> Admin To</li>' +
' {{/type_group}}' +
' {{#expand}}' +
' <li onclick="unfold({{id}})"><i class="glyphicon glyphicon-screenshot"></i> Expand</li>' +
Expand Down Expand Up @@ -293,7 +293,7 @@ $(document).ready(function(){
$('#searchBar').bind('keypress', function(e){
if (e.which == 13){
if (!pathfindingMode){
doQuery("MATCH (n) WHERE n.name =~ '(?i)" + e.currentTarget.value + ".*' AND NOT n.name ENDS WITH '$' RETURN n");
doQuery("MATCH (n) WHERE n.name =~ '(?i)" + escapeRegExp(e.currentTarget.value) + ".*' RETURN n");
}else{
var start = $('#searchBar').val();
var end = $('#endNode').val();
Expand Down Expand Up @@ -832,8 +832,8 @@ var spotlightData = {};

var cancelQuery = null;

function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
function escapeRegExp(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&');
}

var path = function(nid){
Expand Down Expand Up @@ -1479,7 +1479,7 @@ function doInit(){
headers: {
"Authorization": "Basic bmVvNGo6bmVvNGpq"
},
data: JSON.stringify( { "query" : "MATCH (n) WHERE n.name =~ '(?i)" + query + ".*' AND NOT n.name ENDS WITH '$' RETURN n.name LIMIT 10"}),
data: JSON.stringify( { "query" : "MATCH (n) WHERE n.name =~ '(?i)" + escapeRegExp(query) + ".*' RETURN n.name LIMIT 10"}),
success: function(json) {
var d = json.data
var l = d.length;
Expand All @@ -1491,7 +1491,7 @@ function doInit(){
});
}, afterSelect: function(selected){
if (!pathfindingMode){
doQuery("MATCH (n) WHERE n.name =~ '(?i)" + escapeRegExp(selected) + ".*' AND NOT n.name ENDS WITH '$' RETURN n");
doQuery("MATCH (n) WHERE n.name =~ '(?i)" + escapeRegExp(selected) + ".*' RETURN n");
}else{
var start = $('#searchBar').val();
var end = $('#endNode').val();
Expand All @@ -1513,7 +1513,7 @@ function doInit(){
headers: {
"Authorization": "Basic bmVvNGo6bmVvNGpq"
},
data: JSON.stringify( { "query" : "MATCH (n) WHERE n.name =~ '(?i)" + query + ".*' AND NOT n.name ENDS WITH '$' RETURN n.name LIMIT 10"}),
data: JSON.stringify( { "query" : "MATCH (n) WHERE n.name =~ '(?i)" + escapeRegExp(query) + ".*' RETURN n.name LIMIT 10"}),
success: function(json) {
var d = json.data
var l = d.length;
Expand Down Expand Up @@ -1541,7 +1541,7 @@ function doInit(){
})

// Do this query to set the initial graph
doQuery("MATCH (n:Group {name:\'DOMAIN ADMINS\'})<-[r:MemberOf]-m RETURN n,r,m", "", "", true);
doQuery("MATCH (n:Group {name:\'DOMAIN ADMINS\'})<-[r:MemberOf]-(m) RETURN n,r,m", "", "", true);
}

function startLogout(){
Expand Down

0 comments on commit 0dcc51c

Please sign in to comment.