parseRequestType(event) {
        const path = event["path"];
        // ----
        const matchDefault = new RegExp(/^(\/?)([0-9a-zA-Z+\/]{4})*(([0-9a-zA-Z+\/]{2}==)|([0-9a-zA-Z+\/]{3}=))?$/);
        const matchThumbor = new RegExp(/^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$/i);
        const matchCustom = new RegExp(/(\/?)(.*)(jpg|png|webp|tiff|jpeg)/i);
        const definedEnvironmentVariables = (
            (process.env.REWRITE_MATCH_PATTERN !== "") &&
            (process.env.REWRITE_SUBSTITUTION !== "") &&
            (process.env.REWRITE_MATCH_PATTERN !== undefined) &&
            (process.env.REWRITE_SUBSTITUTION !== undefined)
        );
        // ----
        if (matchDefault.test(path)) {  // use sharp
            return 'Default';
        } else if (matchCustom.test(path) && definedEnvironmentVariables) {  // use rewrite function then thumbor mappings
            return 'Custom';
        } else if (matchThumbor.test(path)) {  // use thumbor mappings
            return 'Thumbor';
        } else {
            throw {
                status: 400,
                code: 'RequestTypeError',
                message: 'The type of request you are making could not be processed. Please ensure that your original image is of a supported file type (jpg, png, tiff, webp) and that your image request is provided in the correct syntax. Refer to the documentation for additional guidance on forming image requests.'
            };
        }
    }
/**
     * Determines how to handle the request being made based on the URL path
     * prefix to the image request. Categorizes a request as either "image"
     * (uses the Sharp library), "thumbor" (uses Thumbor mapping), or "custom"
     * (uses the rewrite function).
     * @param {object} event - Lambda request body.
    */
Determines how to handle the request being made based on the URL path
prefix to the image request.
Determines how to handle the request being made based on the URL path prefix to the image request .
parseRequestType(event) {
        const path = event["path"];
        const matchDefault = new RegExp(/^(\/?)([0-9a-zA-Z+\/]{4})*(([0-9a-zA-Z+\/]{2}==)|([0-9a-zA-Z+\/]{3}=))?$/);
        const matchThumbor = new RegExp(/^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$/i);
        const matchCustom = new RegExp(/(\/?)(.*)(jpg|png|webp|tiff|jpeg)/i);
        const definedEnvironmentVariables = (
            (process.env.REWRITE_MATCH_PATTERN !== "") &&
            (process.env.REWRITE_SUBSTITUTION !== "") &&
            (process.env.REWRITE_MATCH_PATTERN !== undefined) &&
            (process.env.REWRITE_SUBSTITUTION !== undefined)
        );
        if (matchDefault.test(path)) {  
            return 'Default';
        } else if (matchCustom.test(path) && definedEnvironmentVariables) {  
            return 'Custom';
        } else if (matchThumbor.test(path)) {  
            return 'Thumbor';
        } else {
            throw {
                status: 400,
                code: 'RequestTypeError',
                message: 'The type of request you are making could not be processed. Please ensure that your original image is of a supported file type (jpg, png, tiff, webp) and that your image request is provided in the correct syntax. Refer to the documentation for additional guidance on forming image requests.'
            };
        }
    }
parseRequestType ( event ) { const path = event [ "path" ] ; const matchDefault = new RegExp ( / ^(\/?)([0-9a-zA-Z+\/]{4})*(([0-9a-zA-Z+\/]{2}==)|([0-9a-zA-Z+\/]{3}=))?$ / ) ; const matchThumbor = new RegExp ( / ^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$ / i ) ; const matchCustom = new RegExp ( / (\/?)(.*)(jpg|png|webp|tiff|jpeg) / i ) ; const definedEnvironmentVariables = ( ( process . env . REWRITE_MATCH_PATTERN !== "" ) && ( process . env . REWRITE_SUBSTITUTION !== "" ) && ( process . env . REWRITE_MATCH_PATTERN !== undefined ) && ( process . env . REWRITE_SUBSTITUTION !== undefined ) ) ; if ( matchDefault . test ( path ) ) { return 'Default' ; } else if ( matchCustom . test ( path ) && definedEnvironmentVariables ) { return 'Custom' ; } else if ( matchThumbor . test ( path ) ) { return 'Thumbor' ; } else { throw { status : 400 , code : 'RequestTypeError' , message : 'The type of request you are making could not be processed. Please ensure that your original image is of a supported file type (jpg, png, tiff, webp) and that your image request is provided in the correct syntax. Refer to the documentation for additional guidance on forming image requests.' } ; } }
Determines how to handle the request being made based on the URL path
 prefix to the image request.
Determines how to handle the request being made based on the URL path prefix to the image request .
// ---- // ---- // use sharp // use rewrite function then thumbor mappings // use thumbor mappings