Skip to content

Commit

Permalink
fix relative protocol for url2origin in base/util module
Browse files Browse the repository at this point in the history
  • Loading branch information
caijf committed Sep 30, 2017
1 parent 0b8f0dd commit 3fe9605
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.4.6
--------------------------------------------------------
- BUG修复模块
* base/util 模块的 _$url2origin 接口支持相对协议

0.4.5 (2017-09-14)
--------------------------------------------------------
- 功能支持
Expand Down
8 changes: 7 additions & 1 deletion src/base/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,13 @@ NEJ.define([
_p._$url2origin = (function(){
var _reg = /^([\w]+?:\/\/.*?(?=\/|$))/i;
return function(_url){
if (_reg.test(_url||''))
_url = _url||'';
// fix relative protocol
if (_url.indexOf('//')===0){
_url = location.protocol+_url;
}
// dump origin
if (_reg.test(_url))
return RegExp.$1.toLowerCase();
return '';
};
Expand Down

0 comments on commit 3fe9605

Please sign in to comment.