mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-21 21:10:00 +01:00
Improves location check.
This commit is contained in:
parent
8273f0ded0
commit
f65f5021ae
@ -4,12 +4,17 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty
|
||||
var domain = document.domain,
|
||||
location = (function () {
|
||||
|
||||
var location = document.location.pathname.replace(/[^\/]*$/, ''),
|
||||
testpathname = '/a b',
|
||||
a = document.createElement('a');
|
||||
var testpathname = '/a b',
|
||||
a = document.createElement('a'),
|
||||
isDecoded, location;
|
||||
|
||||
a.href = testpathname;
|
||||
if (a.pathname === testpathname) {
|
||||
isDecoded = a.href.replace(/.*:\/\/[^\/]*/, '') === testpathname;
|
||||
|
||||
a.href = '.';
|
||||
location = a.href.replace(/.*:\/\/[^\/]*/, '').replace(/[^\/]*$/, '');
|
||||
|
||||
if (isDecoded) {
|
||||
location = encodeURIComponent(location).replace(/%2F/ig, '/').replace(/'/g, '%27');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user