Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1880 Search fails on Internet Explorer 11 #1881

Merged
Merged
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
22 changes: 13 additions & 9 deletions web/client/utils/TemplateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/

const {isString} = require('lodash');

module.exports = {
/**
* generates a template string to use for static replacements.
Expand All @@ -20,15 +22,17 @@ module.exports = {
var fn = cache[template];

if (!fn) {
// Replace ${expressions} (etc) with ${map.expressions}.
let sanitized = template
.replace(/\$\{([\s]*[^;\s\{]+[\s]*)\}/g, function(_, match) {
return `\$\{map.${match.trim()}\}`;
})
// Afterwards, replace anything that's not ${map.expressions}' (etc) with a blank string.
.replace(/(\$\{(?!map\.)[^}]+\})/g, '');

fn = Function('map', `return \`${sanitized}\``);
fn = (map) => {

let sanitized = template
.replace(/\$\{([\s]*[^;\s\{]+[\s]*)\}/g, (_, match) => {
return match.trim().split(".").reduce((a, b) => {
return a && a[b];
}, map);
});

return isString(sanitized) && sanitized || '';
};
cache[template] = fn;

}
Expand Down