Skip to content

Commit

Permalink
update 1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Mar 18, 2018
1 parent 1a385f0 commit ba74d6b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,13 @@ import XEUtils from 'xe-utils'
XEUtils.locat() // {hash: '', host: '', hostname: '', href: '', protocol: '', port: '', origin: '', query: {...}, params: {...}, ...}
```
### getBaseURL ( ) 获取上下文路径
```shell
import XEUtils from 'xe-utils'

XEUtils.getBaseURL() // http://xuliangzhan.com/demo/
```
### cookie ( ) Cookie操作函数
```shell
import XEUtils from 'xe-utils'
Expand Down
17 changes: 15 additions & 2 deletions dist/xe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,16 @@
return result
}

function getLocatOrigin () {
return $locat.origin || ($locat.protocol + '//' + $locat.host)
}

function getBaseURL () {
var pathname = $locat.pathname
var lastIndex = lastIndexOf(pathname, '/') + 1
return getLocatOrigin() + (lastIndex === pathname.length ? pathname : pathname.substring(0, lastIndex))
}

/**
* 获取地址栏信息
* @return Object
Expand All @@ -1311,7 +1321,7 @@
host: $locat.host,
hostname: $locat.hostname,
protocol: $locat.protocol,
origin: $locat.origin,
origin: getLocatOrigin(),
hash: hash(),
query: parse($locat.hash),
params: parse($locat.search)
Expand All @@ -1320,8 +1330,11 @@

var browseMethods = {
browse: browse,

cookie: cookie,
locat: locat

locat: locat,
getBaseURL: getBaseURL
}

function XEUtils () { }
Expand Down
Loading

0 comments on commit ba74d6b

Please sign in to comment.