-
Notifications
You must be signed in to change notification settings - Fork 0
/
urihandler.common.js
106 lines (106 loc) · 2.96 KB
/
urihandler.common.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Class URIHandler
* The class can be injected into Angular class
* @module SchemeHandler
* @example
* import { URIHandler } from 'tns-ng-urihandler';
*
* export class myApp{
* constructor(private urihandler: URIHandler){
* console.log(this.uriHandler.getURI());
* }
* }
*/
var _URIHandler = (function () {
function _URIHandler() {
}
_URIHandler.prototype._getSearch = function (query) {
if (query === null || query.length == 0) {
return {};
}
var _queries = query.split('&');
var search = {};
_queries.forEach(function (q) {
var _qs = q.split('=');
search[_qs[0]] = _qs[1] ? _qs[1] : null;
});
return search;
};
/**
* @function getURI
* @return {string} Full uri path
*/
_URIHandler.prototype.getURI = function () {
return this.uri;
};
/**
* @function getFragment
* @return {string} the fragment of uri if there's any
* @example
* myapp://host:8080/path/to/my/directory#home-page // return "home-page"
*/
_URIHandler.prototype.getFragment = function () {
return this.fragment;
};
/**
* @function getScheme
* @return {string} the scheme of uri
* @example
* myapp://host:8080/path/to/my/directory // return "myapp"
*/
_URIHandler.prototype.getScheme = function () {
return this.scheme;
};
/**
* @function getQuery
* @return {string} the queries of uri
* @example
* myapp://host:8080/path/to/my/directory?name=Bob // return "name=Bob"
*/
_URIHandler.prototype.getQuery = function () {
return this.query;
};
/**
* @function getPath
* @return {string} the path of uri
* @example
* myapp://host:8080/path/to/my/directory?name=Bob // return "path/to/my/directory"
*/
_URIHandler.prototype.getPath = function () {
return this.path;
};
/**
* @function getHost
* @return {string} the host of uri
* @example
* myapp://host:8080/path/to/my/directory?name=Bob // return "host"
*/
_URIHandler.prototype.getHost = function () {
return this.host;
};
/**
* @function getUser
* @return {string} the user info of uri if any
* @example
* myapp://Alice@host:8080/path/to/my/directory?name=Bob // return "Alice"
*/
_URIHandler.prototype.getUser = function () {
return this.user;
};
/**
* @function getPassword
* @return {string} the password of uri if any
* @example
* myapp://Alice:Passw0rd@host:8080/path/to/my/directory?name=Bob // return "Passw0rd"
*/
_URIHandler.prototype.getPassword = function () {
return this.password;
};
_URIHandler.prototype.search = function () {
return this._getSearch(this.query);
};
return _URIHandler;
}());
exports._URIHandler = _URIHandler;