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: {