Skip to content

Commit 52e23f7

Browse files
author
zhangxinxu
committed
external url judge
external url judge
1 parent f371376 commit 52e23f7

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobilebone",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "Bone main for mobile web APP with a sigle page mode.",
55
"main": "src/mobilebone.js",
66
"directories": {

src/mobilebone.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* @type string
4040
**/
41-
Mobilebone.VERSION = '2.3.0';
41+
Mobilebone.VERSION = '2.3.1';
4242

4343
/**
4444
* Whether catch attribute of href from element with tag 'a'
@@ -828,7 +828,7 @@
828828
// if not ajax request
829829
if (target.getAttribute("data-rel") == "external"
830830
|| ajax == "false"
831-
|| (href.split("/")[0] !== location.href.split("/")[0] && ajax != "true")
831+
|| (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0] && ajax != "true")
832832
|| (Mobilebone.captureLink == false && ajax != "true")
833833
) return;
834834

@@ -917,7 +917,7 @@
917917
if (/^javascript/.test(href)) {
918918
if (back == false) return;
919919
} else {
920-
external = external || (href.split("/")[0] !== location.href.split("/")[0]);
920+
external = external || (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0]);
921921
if ((external == true || capture == false) && target.getAttribute("data-ajax") != "true") return;
922922
}
923923

test/ajax-html/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div id="container"></div>
1313
<div id="pageHome" class="page out">
1414
<ul>
15-
<li><a href="ajax-page.html" data-container="container">点击加载(缓存,若后2项已请求,则无请求)</a></li>
15+
<li><a href="http://localhost/GitHub/mobilebone/test/ajax-html/ajax-page.html" data-container="container">点击加载(缓存,若后2项已请求,则无请求)</a></li>
1616
<li><a href="ajax-page.html" data-reload>点击加载(每次都请求, 返回含page结构)</a></li>
1717
<li><a href="ajax-page.html?&&" data-formdata="?a=1">点击加载(缓存, url过滤测试)</a></li>
1818
<li><a href="ajax-page.html?a" data-reload data-formdata="?a=1">点击加载(data-formdata测试)-全覆盖loading</a></li>
@@ -25,6 +25,9 @@
2525
<ul>
2626
<li><a href="b.html">连续加载测试-加载b页面</a></li>
2727
</ul>
28+
<ul>
29+
<li><a href="http://www.zhangxinxu.com/sp/char.html" target="_blank">外部地址测试,应该直接跳转</a></li>
30+
</ul>
2831
<ul>
2932
<li><a href="../index.html" data-ajax="false">&laquo; 返回测试引导首页</a></li>
3033
</ul>

0 commit comments

Comments
 (0)