Commit 3714c0aa authored by Mahdi Mahmoudy's avatar Mahdi Mahmoudy
Browse files

Merge branch 'brakets-issue'

parents 0442b51b 7e6e5ea3
......@@ -323,9 +323,20 @@ wsService.factory('searchService', [
'$http',
'ENV',
function ($http, ENV) {
// to escape special characters which aren't supported
// by the API end-point
function escapeSearchTerm(searchTerm) {
if (!searchTerm) {
return searchTerm;
}
return searchTerm
.replace(/\[(.*)\]/, "%5B$1%5D"); // [ and ]
};
return {
findTerms: function (searchTerm, limit, page, facet, filters) {
var url = ENV.apiEndpoint + '/internal/search/ontology?query=' + searchTerm + '&limit=' + limit + '&page=' + (page
var url = ENV.apiEndpoint + '/internal/search/ontology?query=' + escapeSearchTerm(searchTerm) + '&limit=' + limit + '&page=' + (page
? page
: 1) + '&facet=' + (facet
? facet
......@@ -335,7 +346,7 @@ wsService.factory('searchService', [
return $http.get(url);
},
findGeneProducts: function (searchTerm, limit, page, facet, filters) {
var url = ENV.apiEndpoint + '/geneproduct/search?query=' + searchTerm + '&limit=' + limit + '&page=' + (page
var url = ENV.apiEndpoint + '/geneproduct/search?query=' + escapeSearchTerm(searchTerm) + '&limit=' + limit + '&page=' + (page
? page
: 1) + '&facet=' + (facet
? facet
......@@ -356,13 +367,13 @@ wsService.factory('searchService', [
return $http.get(url);
},
getAnnotationsForTermUrl: function (searchTerm) {
return 'goUsage=descendants&goUsageRelationships=is_a,part_of,occurs_in&goId=' + searchTerm;
return 'goUsage=descendants&goUsageRelationships=is_a,part_of,occurs_in&goId=' + escapeSearchTerm(searchTerm);
},
getAnnotationsForECOUrl: function (searchTerm) {
return 'evidenceCodeUsage=descendants&evidenceCode=' + searchTerm;
return 'evidenceCodeUsage=descendants&evidenceCode=' + escapeSearchTerm(searchTerm);
},
getAnnotationsForProductUrl: function (searchTerm) {
return 'geneProductId=' + searchTerm;
return 'geneProductId=' + escapeSearchTerm(searchTerm);
},
findAnnotationsForFilterUrl: function (url) {
return $http.get(ENV.apiEndpoint + '/annotation/search?' + url);
......@@ -375,7 +386,8 @@ wsService.factory('searchService', [
}
});
return queryString;
}
},
escapeSearchTerm: escapeSearchTerm,
};
}
]);
......
......@@ -107,7 +107,10 @@ app.controller('FacetSearchCtrl', function($scope, $location, searchService, $ro
if (!text) {
return text;
}
return text.replace(new RegExp($scope.searchTerm, 'gi'), '<em>' + $scope.searchTerm + '</em>');
return text.replace(
new RegExp(searchService.escapeSearchTerm($scope.searchTerm), 'gi'),
'<em>' + $scope.searchTerm + '</em>'
);
};
getResultsPage(type);
......
'use strict';
app.controller('SearchCtrl', function($scope, $location, $routeParams) {
$scope.searchTerm = $routeParams.searchTerm
.replace(/\[(.*)\]/, "%5B$1%5D");
app.controller('SearchCtrl', function($scope, $location, $routeParams, searchService) {
$scope.searchTerm = $routeParams.searchTerm;
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment