@serverless-stack/nextjs-lambda
Version:
Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge
32 lines (28 loc) • 911 B
JavaScript
var serdePlugin = require('./serdePlugin-26c3933d.js');
/**
* Validate whether a string is an ARN.
*/
var validate = function (str) {
return typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
};
/**
* Parse an ARN string into structure with partition, service, region, accountId and resource values
*/
var parse = function (arn) {
var segments = arn.split(":");
if (segments.length < 6 || segments[0] !== "arn")
throw new Error("Malformed ARN");
var _a = serdePlugin.__read(segments),
//Skip "arn" literal
partition = _a[1], service = _a[2], region = _a[3], accountId = _a[4], resource = _a.slice(5);
return {
partition: partition,
service: service,
region: region,
accountId: accountId,
resource: resource.join(":"),
};
};
exports.parse = parse;
exports.validate = validate;
;