mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 10:26:08 -06:00
Tweaks to url shortener service changes
This commit is contained in:
@@ -362,14 +362,14 @@ aws.initConfig(awsProps)
|
||||
next({status: 404, message: `page "${req.path}" could not be found`});
|
||||
})
|
||||
.use(Sentry.Handlers.errorHandler)
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
.use((err, req, res, next) => {
|
||||
const status =
|
||||
err.status ||
|
||||
err.statusCode ||
|
||||
err.status_code ||
|
||||
(err.output && err.output.statusCode) ||
|
||||
500;
|
||||
err.status ||
|
||||
err.statusCode ||
|
||||
err.status_code ||
|
||||
(err.output && err.output.statusCode) ||
|
||||
500;
|
||||
const message = err.message || 'Internal Server Error';
|
||||
res.status(status);
|
||||
res.render('error', renderConfig({error: {code: status, message: message}}));
|
||||
@@ -573,7 +573,7 @@ aws.initConfig(awsProps)
|
||||
// Based on combined format, but: GDPR compliant IP, no timestamp & no unused fields for our usecase
|
||||
const morganFormat = isDevMode() ? 'dev' : ':gdpr_ip ":method :url" :status';
|
||||
|
||||
var shortener = require('./lib/shortener-' + ceProps('urlShortenService', 'default'));
|
||||
const shortener = require(`./lib/shortener-${clientOptionsHandler.options.urlShortenService}`);
|
||||
|
||||
router
|
||||
.use(Sentry.Handlers.requestHandler())
|
||||
|
||||
@@ -14,7 +14,6 @@ proxyRetries=300
|
||||
proxyRetryMs=500
|
||||
rescanCompilerSecs=3600
|
||||
sentryDsn=https://8e4614f649ad4e3faf3e7e8827b935f9@sentry.io/102028
|
||||
urlShortenService=google
|
||||
formatters=clangformat
|
||||
formatter.clangformat.name=clang-format
|
||||
formatter.clangformat.exe=/opt/compiler-explorer/clang-trunk/bin/clang-format
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
extraBodyClass=beta
|
||||
httpRoot=/beta
|
||||
urlShortenService=none
|
||||
storageSolution=s3
|
||||
motdUrl=https://s3.dualstack.us-east-1.amazonaws.com/compiler-explorer/motd/motd-beta.json
|
||||
|
||||
@@ -79,7 +79,7 @@ class ClientOptionsHandler {
|
||||
githubEnabled: ceProps('clientGitHubRibbonEnabled', true),
|
||||
gapiKey: ceProps('googleApiKey', ''),
|
||||
googleShortLinkRewrite: ceProps('googleShortLinkRewrite', '').split('|'),
|
||||
urlShortenService: ceProps('urlShortenService', 'none'),
|
||||
urlShortenService: ceProps('urlShortenService', 'default'),
|
||||
defaultSource: ceProps('defaultSource', ''),
|
||||
compilers: [],
|
||||
libs: libs,
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var request = require("request");
|
||||
const request = require("request");
|
||||
|
||||
function handler(req, res) {
|
||||
var url = req.protocol + '://' + req.get('host') + "#" + req.body.config;
|
||||
var options = {
|
||||
const url = `${req.protocol}://${req.get('host')}#${req.body.config}`;
|
||||
const options = {
|
||||
url: "https://tinyurl.com/api-create.php?url=" + encodeURIComponent(url),
|
||||
method: "GET",
|
||||
method: "GET"
|
||||
};
|
||||
var callback = function (err, resp, body) {
|
||||
const callback = (err, resp, body) => {
|
||||
if (!err && resp.statusCode === 200) {
|
||||
res.set('Content-Type', 'application/json');
|
||||
res.send(JSON.stringify({url: body}));
|
||||
|
||||
Reference in New Issue
Block a user