MCPcopy Index your code
hub / github.com/scality/cloudserver / extractRedirectInfo

Function extractRedirectInfo

lib/api/apiUtils/object/websiteServing.js:72–90  ·  view source on GitHub ↗

* extractRedirectInfo - convert location saved from x-amz-website header to * same format as redirectInfo saved from a put bucket website configuration * @param {string} location - location to redirect to * @return {object} redirectInfo - select key/values stored in * WebsiteConfiguration for a

(location)

Source from the content-addressed store, hash-verified

70 * WebsiteConfiguration for a redirect -- protocol, replaceKeyWith and hostName
71 */
72function extractRedirectInfo(location) {
73 const redirectInfo = { redirectLocationHeader: true };
74 if (location.startsWith('/')) {
75 // redirect to another object in bucket
76 redirectInfo.replaceKeyWith = location.slice(1);
77 // when redirect info is set by x-amz-website-redirect-location header
78 // to another key in the same bucket
79 // AWS only returns the path in the location response header
80 redirectInfo.justPath = true;
81 } else if (location.startsWith('https')) {
82 // otherwise, redirect to another website
83 redirectInfo.protocol = 'https';
84 redirectInfo.hostName = location.slice(8);
85 } else {
86 redirectInfo.protocol = 'http';
87 redirectInfo.hostName = location.slice(7);
88 }
89 return redirectInfo;
90}
91
92/**
93 * validateWebsiteHeader description]

Callers 1

runWebsiteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected