Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: update JSDoc for subdomains getter and simplify implementation #6135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,18 @@ defineGetter(req, 'ips', function ips() {
* If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.
* If "subdomain offset" is 3, req.subdomains is `["tobi"]`.
*
* @return {Array}
* @return {Array<String>}
* @public
*/

defineGetter(req, 'subdomains', function subdomains() {
var hostname = this.hostname;

defineGetter(req, 'subdomains', function() {
const { hostname, app } = this;
if (!hostname) return [];

var offset = this.app.get('subdomain offset');
var subdomains = !isIP(hostname)
? hostname.split('.').reverse()
: [hostname];
const offset = app.get('subdomain offset');
const subdomains = isIP(hostname)
? [hostname]
: hostname.split('.').reverse();

return subdomains.slice(offset);
});
Expand Down