Skip to content

Commit

Permalink
Added $.address property.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Oct 22, 2024
1 parent f612b09 commit bfbdd23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Options.prototype = {
return this.controller ? this.controller.ip : null;
},

get address() {
return this.controller ? this.controller.address : null;
},

get files() {
return this.controller ? this.controller.files : null;
},
Expand Down Expand Up @@ -1457,6 +1461,11 @@ ActionCaller.prototype.error = function(value) {
return this;
};

ActionCaller.prototype.ctrl = function(ctrl) {
this.controller = ctrl ? (ctrl.controller || ctrl) : null;
return this;
};

ActionCaller.prototype.done = function($, fn) {
this.options.callback = function(err, response) {
if (err)
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

- improved user-agent parser (added support for new headers `Sec-CH-UA`)
- improved `Number.pluralize()` method
- Reduced DNS cache flush time to 3 minutes
- reduced DNS cache flush time to 3 minutes
- added `$.address` property with the absolute URL address
- added `$.ctrl(ctrl_instance)` method

========================
0.0.6
Expand Down
6 changes: 5 additions & 1 deletion controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Controller(req, res) {
ctrl.url = ctrl.uri.pathname;
ctrl.released = false;
ctrl.downloaded = false;
ctrl.protocol = req.connection.encrypted || (req.headers['x-forwarded-protocol'] || req.headers['x-forwarded-proto']) === 'https' ? 'https' : 'http';
ctrl.protocol = req.connection.encrypted || req.headers['x-forwarded-ssl'] === 'on' || req.headers['x-forwarded-port'] === '443' || (req.headers['x-forwarded-proto'] || req.headers['x-forwarded-protocol']) === 'https' ? 'https' : 'http';

for (let path of ctrl.split)
ctrl.split2.push(path.toLowerCase());
Expand Down Expand Up @@ -159,6 +159,10 @@ Controller.prototype = {

get host() {
return this.headers.host;
},

get address() {
return (this.protocol + '://' + this.headers?.host || '') + (this.req?.url || '');
}

};
Expand Down

0 comments on commit bfbdd23

Please sign in to comment.