File tree Expand file tree Collapse file tree 4 files changed +43
-18
lines changed
Expand file tree Collapse file tree 4 files changed +43
-18
lines changed Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change 11import 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 */
108export 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,
Original file line number Diff line number Diff line change 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+ */
You can’t perform that action at this time.
0 commit comments