Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/util/backwards_compatibility.js (JavaScript)

Code before:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import isObject from './is_object';

const oldBool = val => val.toString().trim() === '' ? true : val;

const globalMap = {
    ssl_profile:                ['https', 'sslProfile'],
    resolver_cloudflare:        ['https', 'ocspCloudflare', oldBool],
    resolver_google:            ['https', 'ocspGoogle', oldBool],
    resolver_opendns:           ['https', 'ocspOpenDns', oldBool],
    directory_letsencrypt:      ['https', 'letsEncryptRoot'],

    referrer_policy:            ['security', 'referrerPolicy'],
    security_txt:               ['security', 'securityTxt', oldBool],
    security_txt_path:          ['security', 'securityTxtPreferredLanguages'],
    content_security_policy:    ['security', 'contentSecurityPolicy'],
    server_tokens:              ['security', 'serverTokens', oldBool],
    limit_req:                  ['security', 'limitReq', oldBool],

    php_server:                 ['php', 'phpServer'],
    php_server_backup:          ['php', 'phpBackupServer'],

    python_server:              ['python', 'pythonServer'],

    gzip:                       ['performance', 'gzipCompression', oldBool],
    brotli:                     ['performance', 'brotliCompression', oldBool],
    expires_assets:             ['performance', 'assetsExpiration'],
    expires_media:              ['performance', 'mediaExpiration'],
    expires_svg:                ['performance', 'svgExpiration'],
    expires_fonts:              ['performance', 'fontsExpiration'],

    access_log:                 ['logging', 'accessLog'],
    error_log:                  ['logging', 'errorLog'],
    log_not_found:              ['logging', 'logNotFound', oldBool],

    directory_nginx:            ['nginx', 'nginxConfigDirectory'],
    worker_processes:           ['nginx', 'workerProcesses'],
    user:                       ['nginx', 'user'],
    pid:                        ['nginx', 'pid'],
    client_max_body_size:       ['nginx', 'clientMaxBodySize'],

Review comment (security):
```suggestion
```
These aren't needed, settings for security.txt never existed on the old version of the tool, so there is no backwards compatibility to support.

Code after:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import isObject from './is_object';

const oldBool = val => val.toString().trim() === '' ? true : val;

const globalMap = {
    ssl_profile:                ['https', 'sslProfile'],
    resolver_cloudflare:        ['https', 'ocspCloudflare', oldBool],
    resolver_google:            ['https', 'ocspGoogle', oldBool],
    resolver_opendns:           ['https', 'ocspOpenDns', oldBool],
    directory_letsencrypt:      ['https', 'letsEncryptRoot'],

    referrer_policy:            ['security', 'referrerPolicy'],
    content_security_policy:    ['security', 'contentSecurityPolicy'],
    server_tokens:              ['security', 'serverTokens', oldBool],
    limit_req:                  ['security', 'limitReq', oldBool],

    php_server:                 ['php', 'phpServer'],
    php_server_backup:          ['php', 'phpBackupServer'],

    python_server:              ['python', 'pythonServer'],

    gzip:                       ['performance', 'gzipCompression', oldBool],
    brotli:                     ['performance', 'brotliCompression', oldBool],
    expires_assets:             ['performance', 'assetsExpiration'],
    expires_media:              ['performance', 'mediaExpiration'],
    expires_svg:                ['performance', 'svgExpiration'],
    expires_fonts:              ['performance', 'fontsExpiration'],

    access_log:                 ['logging', 'accessLog'],
    error_log:                  ['logging', 'errorLog'],
    log_not_found:              ['logging', 'logNotFound', oldBool],

    directory_nginx:            ['nginx', 'nginxConfigDirectory'],
    worker_processes:           ['nginx', 'workerProcesses'],
    user:                       ['nginx', 'user'],
    pid:                        ['nginx', 'pid'],
    client_max_body_size:       ['nginx', 'clientMaxBodySize'],

    file_structure:             ['tools', 'modularizedStructure', val => val.toLowerCase().trim() === 'modularized'],