Total Complexity | 4 |
Complexity/F | 1.33 |
Lines of Code | 19 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | import { uri } from 'unity-utils'; |
||
2 | import { format } from 'url'; |
||
3 | |||
4 | export function getAPIPrefix(APINamespace) { |
||
5 | const reAbsolute = /^(\/|https?:\/\/)/ig; |
||
6 | return reAbsolute.test(APINamespace) ? APINamespace : '/' + APINamespace; |
||
7 | } |
||
8 | |||
9 | export function getFullPath(APINamespace, namespace, path=[]) { |
||
10 | path = [].concat(path); |
||
11 | return uri.join(getAPIPrefix(APINamespace), namespace, ...path).replace(':/', '://'); |
||
12 | } |
||
13 | |||
14 | export function formatURL(APINamespace = '', namespace = '', path=[], query={}) { |
||
15 | return format({ |
||
16 | pathname: getFullPath(APINamespace, namespace, path), |
||
17 | query: uri.query(query) |
||
18 | }); |
||
19 | } |