ソースを参照

Escape shortPath

Sotaro KARASAWA 9 年 前
コミット
40141b37d1
1 ファイル変更2 行追加1 行削除
  1. 2 1
      resource/js/components/PageList/PagePath.js

+ 2 - 1
resource/js/components/PageList/PagePath.js

@@ -28,7 +28,8 @@ export default class PagePath extends React.Component {
     const page = this.props.page;
     const pagePath = page.path.replace(this.props.excludePathString.replace(/^\//, ''), '');
     const shortPath = this.getShortPath(pagePath);
-    const pathPrefix = pagePath.replace(new RegExp(shortPath + '(/)?$'), '');
+    const shortPathEscaped = shortPath.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+    const pathPrefix = pagePath.replace(new RegExp(shortPathEscaped + '(/)?$'), '');
 
     return (
       <span className="page-path">