parseRedirectsFile = (content, ext) => {
    if (ext === '.json') {
        let redirects;

        try {
            redirects = JSON.parse(content);
        } catch (err) {
            throw new errors.BadRequestError({
                message: tpl(messages.jsonParse, {context: err.message})
            });
        }

        return redirects;
    }

    if (ext === '.yaml') {
        let redirects = [];
        let configYaml;

        try {
            configYaml = yaml.load(content);
        } catch (err) {
            throw new errors.BadRequestError({
                message: tpl(messages.yamlParse, {context: err.message})
            });
        }

        if (typeof configYaml !== 'object' || configYaml === null) {
            throw new errors.BadRequestError({
                message: tpl(messages.yamlInvalid),
                help: tpl(messages.redirectsHelp)
            });
        }

        /**
         * 302: Temporary redirects
         */
        for (const redirect in configYaml['302']) {
            redirects.push({
                from: redirect,
                to: configYaml['302'][redirect],
                permanent: false
            });
        }

        /**
         * 301: Permanent redirects
         */
        for (const redirect in configYaml['301']) {
            redirects.push({
                from: redirect,
                to: configYaml['301'][redirect],
                permanent: true
            });
        }

        return redirects;
    }

    throw new errors.IncorrectUsageError();
}
@param {String} content serialized JSON or YAML configuration
@param {String} ext one of `.json` or `.yaml` extensions

@returns {RedirectConfig[]} of parsed redirect config objects