forked from bingoogolapple/bga_issue_blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (36 loc) · 1011 Bytes
/
index.js
File metadata and controls
41 lines (36 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Created by bingoogolapple on 2017/7/13.
*/
const gitHubApi = require('./gitHubApi')
const isGetUserInfo = (vm, config) => {
return config && (config.url === `https://api.github.com/repos/${vm.$store.getters.repo}/labels` || config.url === `https://api.github.com/users/${vm.$store.getters.gitHubUsername}`)
}
const queryParse = (search = window.location.search) => {
if (!search) {
return {}
} else {
const queryString = search[0] === '?' ? search.substring(1) : search
const query = {}
queryString
.split('&')
.forEach(queryStr => {
const [key, value] = queryStr.split('=')
if (key) {
query[decodeURIComponent(key)] = decodeURIComponent(value)
}
})
return query
}
}
const queryStringify = query => {
const queryString = Object.keys(query)
.map(key => `${key}=${encodeURIComponent(query[key] || '')}`)
.join('&')
return queryString
}
export {
gitHubApi,
isGetUserInfo,
queryParse,
queryStringify
}