Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/generators/conf/website.conf.js (JavaScript)

Code before:
    }
    return config;
};

const httpsListen = domain => {
    const config = [];

    // HTTPS
    config.push(['listen', 
        `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}443 ssl` 
        + `${domain.https.http2.computed ? ' http2' : '' }`,
    ]);

    // HTTP/3
    if (domain.https.http3.computed)
        config.push(['listen',
            `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}443 ssl http3` 
            + `${domain.https.portReuse.computed ? ' reuseport' : ''}`,
        ]);
    
    // v6
    if (domain.server.listenIpv6.computed)
        config.push(['listen',
            `[${domain.server.listenIpv6.computed}]:443 ssl`
            + `${domain.https.http2.computed ? ' http2' : '' }`,
        ]);

    // v6 HTTP/3
    if (domain.server.listenIpv6.computed && domain.https.http3.computed)
        config.push(['listen',
            `[${domain.server.listenIpv6.computed}]:443 ssl http3`
            + `${domain.https.portReuse.computed ? ' reuseport' : ''}`,
        ]);
    return config;
};

const httpListen = domain => {
    const config = [];

    // Not HTTPS
    config.push(['listen', `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}80`]);

    // v6
    if (domain.server.listenIpv6.computed)
        config.push(['listen', `[${domain.server.listenIpv6.computed}]:80`]);

    return config;
};

const listenConfig = domain => {
    if (domain.https.https.computed) return httpsListen(domain);

Review comment (suggestion):
```suggestion
            `[${domain.server.listenIpv6.computed}]:443 ssl${domain.https.http2.computed ? ' http2' : ''}`]);
```
Ditto re: reverting formatting changes for cleaner diff :)

Code after:
    }
    return config;
};

const httpsListen = domain => {
    const config = [];

    // HTTPS
    config.push(['listen', `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}443 ssl${domain.https.http2.computed ? ' http2' : ''}`]);

    // HTTP/3
    if (domain.https.http3.computed)
        config.push(['listen',
            `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}443 http3` 
            + `${domain.https.portReuse.computed ? ' reuseport' : ''}`,
        ]);

    // v6
    if (domain.server.listenIpv6.computed)
        config.push(['listen',
            `[${domain.server.listenIpv6.computed}]:443 ssl${domain.https.http2.computed ? ' http2' : ''}`]);

    // v6 HTTP/3
    if (domain.server.listenIpv6.computed && domain.https.http3.computed)
        config.push(['listen',
            `[${domain.server.listenIpv6.computed}]:443 http3${domain.https.portReuse.computed ? ' reuseport' : ''}`,
        ]);
    return config;
};

const httpListen = domain => {
    const config = [];

    // Not HTTPS
    config.push(['listen', `${domain.server.listenIpv4.computed === '*' ? '' : `${domain.server.listenIpv4.computed}:`}80`]);

    // v6
    if (domain.server.listenIpv6.computed)
        config.push(['listen', `[${domain.server.listenIpv6.computed}]:80`]);

    return config;
};

const listenConfig = domain => {
    if (domain.https.https.computed) return httpsListen(domain);
    return httpListen(domain);
};


const httpRedirectConfig = (domain, global, domainName, redirectDomain) => {
    // Build the server config on its own before adding it to the parent config