parseImageBucket(event, requestType) {
        if (requestType === "Default") {
            // Decode the image request
            const decoded = this.decodeRequest(event);
            if (decoded.bucket !== undefined) {
                // Check the provided bucket against the whitelist
                const sourceBuckets = this.getAllowedSourceBuckets();
                if (sourceBuckets.includes(decoded.bucket) || decoded.bucket.match(new RegExp('^' + sourceBuckets[0] + '$'))) {
                    return decoded.bucket;
                } else {
                    throw ({
                        status: 403,
                        code: 'ImageBucket::CannotAccessBucket',
                        message: 'The bucket you specified could not be accessed. Please check that the bucket is specified in your SOURCE_BUCKETS.'
                    });
                }
            } else {
                // Try to use the default image source bucket env var
                const sourceBuckets = this.getAllowedSourceBuckets();
                return sourceBuckets[0];
            }
        } else if (requestType === "Thumbor" || requestType === "Custom") {
            // Use the default image source bucket env var
            const sourceBuckets = this.getAllowedSourceBuckets();
            return sourceBuckets[0];
        } else {
            throw ({
                status: 404,
                code: 'ImageBucket::CannotFindBucket',
                message: 'The bucket you specified could not be found. Please check the spelling of the bucket name in your request.'
            });
        }
    }
/**
     * Parses the name of the appropriate Amazon S3 bucket to source the
     * original image from.
     * @param {string} event - Lambda request body.
     * @param {string} requestType - Image handler request type.
     */
Parses the name of the appropriate Amazon S3 bucket to source the
original image from.
@param {string} event - Lambda request body.
@param {string} requestType - Image handler request type.
Parses the name of the appropriate Amazon S3 bucket to source the original image from . @param { string } event - Lambda request body . @param { string } requestType - Image handler request type .
parseImageBucket(event, requestType) {
        if (requestType === "Default") {
            const decoded = this.decodeRequest(event);
            if (decoded.bucket !== undefined) {
                const sourceBuckets = this.getAllowedSourceBuckets();
                if (sourceBuckets.includes(decoded.bucket) || decoded.bucket.match(new RegExp('^' + sourceBuckets[0] + '$'))) {
                    return decoded.bucket;
                } else {
                    throw ({
                        status: 403,
                        code: 'ImageBucket::CannotAccessBucket',
                        message: 'The bucket you specified could not be accessed. Please check that the bucket is specified in your SOURCE_BUCKETS.'
                    });
                }
            } else {
                const sourceBuckets = this.getAllowedSourceBuckets();
                return sourceBuckets[0];
            }
        } else if (requestType === "Thumbor" || requestType === "Custom") {
            const sourceBuckets = this.getAllowedSourceBuckets();
            return sourceBuckets[0];
        } else {
            throw ({
                status: 404,
                code: 'ImageBucket::CannotFindBucket',
                message: 'The bucket you specified could not be found. Please check the spelling of the bucket name in your request.'
            });
        }
    }
parseImageBucket ( event , requestType ) { if ( requestType === "Default" ) { const decoded = this . decodeRequest ( event ) ; if ( decoded . bucket !== undefined ) { const sourceBuckets = this . getAllowedSourceBuckets ( ) ; if ( sourceBuckets . includes ( decoded . bucket ) || decoded . bucket . match ( new RegExp ( '^' + sourceBuckets [ 0 ] + '$' ) ) ) { return decoded . bucket ; } else { throw ( { status : 403 , code : 'ImageBucket::CannotAccessBucket' , message : 'The bucket you specified could not be accessed. Please check that the bucket is specified in your SOURCE_BUCKETS.' } ) ; } } else { const sourceBuckets = this . getAllowedSourceBuckets ( ) ; return sourceBuckets [ 0 ] ; } } else if ( requestType === "Thumbor" || requestType === "Custom" ) { const sourceBuckets = this . getAllowedSourceBuckets ( ) ; return sourceBuckets [ 0 ] ; } else { throw ( { status : 404 , code : 'ImageBucket::CannotFindBucket' , message : 'The bucket you specified could not be found. Please check the spelling of the bucket name in your request.' } ) ; } }
Parses the name of the appropriate Amazon S3 bucket to source the
 original image from.
Parses the name of the appropriate Amazon S3 bucket to source the original image from .
// Decode the image request // Check the provided bucket against the whitelist // Try to use the default image source bucket env var // Use the default image source bucket env var