소스 검색

Escape shortPath

Sotaro KARASAWA 10 년 전
부모
커밋
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">