Skip to content

Commit eb58390

Browse files
committed
🐞 fix query param absolute path. #829
1 parent ddab0fe commit eb58390

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

β€Žjs/core.jsβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ proto.updateGetPathTemplate = function( optPath ) {
235235
// convert path option into regex to look for pattern in location
236236
// escape query (?) in url, allows for parsing GET parameters
237237
var regexString = optPath
238-
.replace(/(?<!\\)\?/, '\\?')
238+
.replace( /(?<!\\)\?/, '\\?' )
239239
.replace( '{{#}}', '(\\d\\d?\\d?)' );
240240
var templateRe = new RegExp( regexString );
241241
var match = location.href.match( templateRe );
@@ -299,9 +299,17 @@ proto.updateGetAbsolutePath = function() {
299299
}
300300

301301
var pathname = location.pathname;
302+
// query parameter #829. example.com/?pg=2
303+
var isQuery = path.match( /^\?/ );
304+
if ( isQuery ) {
305+
this.getAbsolutePath = function() {
306+
return pathname + this.getPath();
307+
};
308+
return;
309+
}
310+
302311
// /foo/bar/index.html => /foo/bar
303312
var directory = pathname.substring( 0, pathname.lastIndexOf('/') );
304-
305313
this.getAbsolutePath = function() {
306314
return directory + '/' + this.getPath();
307315
};

0 commit comments

Comments
Β (0)