mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 20:44:53 -04:00
Improves location check.
This commit is contained in:
parent
8273f0ded0
commit
f65f5021ae
1 changed files with 9 additions and 4 deletions
|
@ -4,12 +4,17 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty
|
||||||
var domain = document.domain,
|
var domain = document.domain,
|
||||||
location = (function () {
|
location = (function () {
|
||||||
|
|
||||||
var location = document.location.pathname.replace(/[^\/]*$/, ''),
|
var testpathname = '/a b',
|
||||||
testpathname = '/a b',
|
a = document.createElement('a'),
|
||||||
a = document.createElement('a');
|
isDecoded, location;
|
||||||
|
|
||||||
a.href = testpathname;
|
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');
|
location = encodeURIComponent(location).replace(/%2F/ig, '/').replace(/'/g, '%27');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue