Explorar el Código

Merge branch 'master' into feature-search

Sotaro KARASAWA hace 10 años
padre
commit
8a8db161ee
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      resource/js/crowi.js

+ 6 - 1
resource/js/crowi.js

@@ -356,7 +356,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>'));
   });
 
   // for list page