From 722842b0b4fa173454158106d725244dc85999bc Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 3 Feb 2021 20:49:21 +1300 Subject: [PATCH] Support youtu.be redirection --- api/redirects.js | 10 ++++++++++ utils/constants.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 api/redirects.js diff --git a/api/redirects.js b/api/redirects.js new file mode 100644 index 0000000..add9e07 --- /dev/null +++ b/api/redirects.js @@ -0,0 +1,10 @@ +const constants = require("../utils/constants") +const {redirect} = require("pinski/plugins") + +module.exports = [ + { + route: `/(${constants.regex.video_id})`, priority: -1, methods: ["GET"], code: async ({fill}) => { + return redirect(`/watch?v=${fill[0]}`, 301) + } + } +] diff --git a/utils/constants.js b/utils/constants.js index 380bf20..da3d161 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -28,7 +28,7 @@ let constants = { regex: { ucid: "[A-Za-z0-9-_]+", - video_id: "[A-Za-z0-9-_]+" + video_id: "[A-Za-z0-9-_]{11,}" }, symbols: {