浏览代码

Fix not to higilight (<strong>)

Norio Suzuki 10 年之前
父节点
当前提交
e8857f0a70
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      resource/js/crowi.js

+ 6 - 1
resource/js/crowi.js

@@ -319,7 +319,12 @@ $(function() {
     var path = $link.data('path');
     var shortPath = $link.data('short-path');
 
-    $link.html(path.replace(new RegExp(shortPath + '(/)?$'), '<strong>' + shortPath + '$1</strong>'));
+    var escape = function(s) {
+      return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+    };
+    var pattern = escape(shortPath) + '(/)?$';
+
+    $link.html(path.replace(new RegExp(pattern), '<strong>' + shortPath + '$1</strong>'));
   });