Procházet zdrojové kódy

Improved DevidedPagePath for non-chrome browsers

Taichi Masuyama před 4 roky
rodič
revize
ea5fd34f37
1 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 11 2
      packages/core/src/models/devided-page-path.js

+ 11 - 2
packages/core/src/models/devided-page-path.js

@@ -2,8 +2,9 @@ import * as pathUtils from '../utils/path-utils';
 
 
 // https://regex101.com/r/BahpKX/2
 // https://regex101.com/r/BahpKX/2
 const PATTERN_INCLUDE_DATE = /^(.+\/[^/]+)\/(\d{4}|\d{4}\/\d{2}|\d{4}\/\d{2}\/\d{2})$/;
 const PATTERN_INCLUDE_DATE = /^(.+\/[^/]+)\/(\d{4}|\d{4}\/\d{2}|\d{4}\/\d{2}\/\d{2})$/;
-// https://regex101.com/r/HJNvMW/1
-const PATTERN_DEFAULT = /^((.*)(?<!<)\/)?(.+)$/;
+
+// (?<!filename)\.js$
+// ^(?:(?!filename\.js$).)*\.js$
 
 
 export class DevidedPagePath {
 export class DevidedPagePath {
 
 
@@ -34,6 +35,14 @@ export class DevidedPagePath {
       }
       }
     }
     }
 
 
+    let PATTERN_DEFAULT = /^((.*)\/)?(.+)$/;
+    try { // for non-chrome browsers
+      PATTERN_DEFAULT = /^((.*)(?<!<)\/)?(.+)$/; // https://regex101.com/r/HJNvMW/1
+    }
+    catch (err) {
+      // lookbehind regex is not supported on non-chrome browsers
+    }
+
     const matchDefault = pagePath.match(PATTERN_DEFAULT);
     const matchDefault = pagePath.match(PATTERN_DEFAULT);
     if (matchDefault != null) {
     if (matchDefault != null) {
       this.isFormerRoot = matchDefault[1] === '/';
       this.isFormerRoot = matchDefault[1] === '/';