Skip to content

Commit f9e28c2

Browse files
author
Nike
committed
refactorizando, arreglando pequeños errores
1 parent 6b0dd1c commit f9e28c2

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

core/http/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class HRequest {
88
* @constructor
99
*/
1010
constructor() {
11-
this.port = Number(location.port || 80);
11+
this.port = Number(location.port || this.isHTTPS() ? 443 : this.isHTTP() ? 80 : undefined);
1212
this.host = location.hostname;
1313
this.params = {};
1414
this.search = this.getQuerySearch();

core/patron.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class Patron extends Route {
6565
/**
6666
* @param {HRequest} request
6767
* @return {Dispatcher}
68-
* @param {function} callback404
68+
* @param {Function} callback404
6969
*/
7070
run(callback404) {
7171
const dispatcher = Dispatcher.createInstance(

core/route/route.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
import RoutePattern from './route-pattern.js';
2+
import '../types.js'
23

34
/**
45
* @class
5-
* @version 0.1.0
6-
* @property {RoutePattern} pattern
7-
* @property {String} _group
8-
* @property {Array} actions
6+
* @version 0.2.0
97
*/
108
export default class Route {
119
/**
12-
* @constructor
10+
* @type {string}
1311
*/
14-
constructor() {
15-
this._group = '';
16-
this.pattern = new RoutePattern();
17-
this.actions = [];
18-
}
12+
_group = '';
13+
14+
/**
15+
* @type {RouteAction[]}
16+
*/
17+
actions = [];
18+
19+
/**
20+
* @type {RoutePattern}
21+
*/
22+
pattern = new RoutePattern();
1923

2024
/**
21-
*
25+
* url groups
2226
* @param {String} url
23-
* @param {Function} fn
27+
* @param {(context: Route)=> any} fn
28+
* @return {Route}
2429
*/
2530
group(url, fn) {
2631
this._group = url;
@@ -30,17 +35,19 @@ export default class Route {
3035
fn(this);
3136

3237
this._group = '';
38+
39+
return this;
3340
}
34-
41+
3542
/**
3643
* define route
3744
* @param {String} url
38-
* @param {Function} option
39-
* @param {String} method
45+
* @param {Function|OptionRoute} option
46+
* @param {String|undefined} method optional parameter, name method of the function
4047
* @return {Route}
4148
*/
4249
hash(url, option, method) {
43-
const path = this.pattern.resolverCondition(this._group+url)
50+
const path = this.pattern.resolverCondition(this._group.concat(url))
4451

4552
this.actions.push({
4653
path,

core/types.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
*
3+
* @typedef {object} OptionDOMLoad
4+
* @property {string[]} css
5+
* @property {string[]} js
6+
*
7+
* @typedef {object} OptionRoute
8+
* @property {Function} controller
9+
* @property {OptionDOMLoad} load
10+
*
11+
*/
12+
13+
/**
14+
* @typedef {object} RouteAction
15+
* @property {string} path
16+
* @property {OptionRoute} option
17+
* @property {string} method
18+
*/

0 commit comments

Comments
 (0)