Browse Source

Escape shortPath

Sotaro KARASAWA 9 years ago
parent
commit
40141b37d1
1 changed files with 2 additions and 1 deletions
  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 page = this.props.page;
     const pagePath = page.path.replace(this.props.excludePathString.replace(/^\//, ''), '');
     const pagePath = page.path.replace(this.props.excludePathString.replace(/^\//, ''), '');
     const shortPath = this.getShortPath(pagePath);
     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 (
     return (
       <span className="page-path">
       <span className="page-path">