Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((res) => {
const revision = res.body.items[0];
if (revision.redirect && req.query.redirect !== false) {
const htmlPath = [rp.domain, 'sys', 'parsoid', 'html', rp[titleParamName]];
if (rp.revision) {
htmlPath.push(`${rp.revision}`);
if (rp.tid) {
htmlPath.push(`${rp.tid}`);
}
}
return hyper.get({
uri: new URI(htmlPath),
})
.then((html) => {
const redirectTitle = mwUtil.extractRedirect(html.body)
// Redirect detected while saving new HTML.
|| html.headers.location;
if (redirectTitle) {
const newParams = Object.assign({}, rp);
newParams[titleParamName] = redirectTitle;
const location = mwUtil.createRelativeTitleRedirect(specInfo.path, req, {
newReqParams: newParams,
titleParamName,
dropPathAfterTitle: true,
});
let contentPromise;
if (options.attach_body_to_redirect) {
.then((res) => {
const revision = res.body.items[0];
if (revision.redirect && req.query.redirect !== false) {
const htmlPath = [rp.domain, 'sys', 'parsoid', 'html', rp[titleParamName]];
if (rp.revision) {
htmlPath.push(`${rp.revision}`);
if (rp.tid) {
htmlPath.push(`${rp.tid}`);
}
}
return hyper.get({
uri: new URI(htmlPath)
})
.then((html) => {
const redirectTitle = mwUtil.extractRedirect(html.body) ||
// Redirect detected while saving new HTML.
html.headers.location;
if (redirectTitle) {
const newParams = Object.assign({}, rp);
newParams[titleParamName] = redirectTitle;
const location = mwUtil.createRelativeTitleRedirect(specInfo.path, req, {
newReqParams: newParams,
titleParamName,
dropPathAfterTitle: true
});
let contentPromise;
if (options.attach_body_to_redirect) {
.forEach((method) => {
const p = paths[pathStr][method];
const uri = new URI(`${server.config.hostPort}/{domain}/v1${pathStr}`, {}, true);
if (!p['x-amples']) {
throw new Error(`${'Method without examples should declare x-monitor: false.'
+ ' Path: '}${pathStr} Method: ${method}`);
}
p['x-amples'].forEach((ex) => {
ex.request = ex.request || {};
ex.request.params = ex.request.params || {};
ex.request.params.domain = ex.request.params.domain ?
betaDomain(ex.request.params.domain) : options.domain;
if (ex.request.params.domain !== options.domain) {
return;
}
ret.push(constructTestCase(
ex.title,
uri.toString({
delete res.headers.location;
}
return res;
});
if (mwUtil.isNoCacheRequest(req)) {
return continueRequest();
}
const titleParamName = options.title ? options.title : 'title';
const checkURIParts = [rp.domain, 'sys', 'page_revisions', 'page', rp[titleParamName]];
if (rp.revision) {
checkURIParts.push(`${rp.revision}`);
}
return hyper.get({ uri: new URI(checkURIParts) })
.then((res) => {
const revision = res.body.items[0];
if (revision.redirect && req.query.redirect !== false) {
const htmlPath = [rp.domain, 'sys', 'parsoid', 'html', rp[titleParamName]];
if (rp.revision) {
htmlPath.push(`${rp.revision}`);
if (rp.tid) {
htmlPath.push(`${rp.tid}`);
}
}
return hyper.get({
uri: new URI(htmlPath)
})
.then((html) => {
const redirectTitle = mwUtil.extractRedirect(html.body) ||
getSummary: (hyper, req) => {
const rp = req.params;
const oldURI = new URI([rp.domain, 'sys', 'summary_old', 'summary', rp.title]);
const newURI = new URI([rp.domain, 'sys', 'summary_new', 'summary', rp.title]);
if (mwUtil.isNoCacheRequest(req) && isNewStorageEnabled(req.params.domain)) {
return P.props({
oldContent: hyper.get({
uri: oldURI,
headers: req.headers,
query: req.query
}),
newContent: hyper.get({
uri: newURI,
headers: req.headers,
query: req.query
})
.catch((e) => {
hyper.log('error/summary_proxy', {
msg: 'New content fetch failure',
error: e
getSummary: (hyper, req) => {
const rp = req.params;
const oldURI = new URI([rp.domain, 'sys', 'summary_old', 'summary', rp.title]);
const newURI = new URI([rp.domain, 'sys', 'summary_new', 'summary', rp.title]);
if (mwUtil.isNoCacheRequest(req) && isNewStorageEnabled(req.params.domain)) {
return P.props({
oldContent: hyper.get({
uri: oldURI,
headers: req.headers,
query: req.query
}),
newContent: hyper.get({
uri: newURI,
headers: req.headers,
query: req.query
})
.catch((e) => {
hyper.log('error/summary_proxy', {
msg: 'New content fetch failure',
delete res.headers.location;
}
return res;
});
if (mwUtil.isNoCacheRequest(req)) {
return continueRequest();
}
const titleParamName = options.title ? options.title : 'title';
const checkURIParts = [rp.domain, 'sys', 'page_revisions', 'page', rp[titleParamName]];
if (rp.revision) {
checkURIParts.push(`${rp.revision}`);
}
return hyper.get({ uri: new URI(checkURIParts) })
.then((res) => {
const revision = res.body.items[0];
if (revision.redirect && req.query.redirect !== false) {
const htmlPath = [rp.domain, 'sys', 'parsoid', 'html', rp[titleParamName]];
if (rp.revision) {
htmlPath.push(`${rp.revision}`);
if (rp.tid) {
htmlPath.push(`${rp.tid}`);
}
}
return hyper.get({
uri: new URI(htmlPath),
})
.then((html) => {
const redirectTitle = mwUtil.extractRedirect(html.body)