Sfoglia il codice sorgente

Merge pull request #76 from crowi/fix-not-strong

Fix not to higilight (<strong>) link
Sotaro KARASAWA 10 anni fa
parent
commit
c6bdf6b9d3
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  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>'));
   });