better open.lbry.com redirect handling for lbry.tv
This commit is contained in:
parent
24edbc085c
commit
8839bb08db
5 changed files with 52 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
|||
const config = {
|
||||
WEBPACK_WEB_PORT: 9090,
|
||||
WEBPACK_ELECTRON_PORT: 9091,
|
||||
WEB_SERVER_PORT: 1337,
|
||||
WEB_SERVER_PORT: 80,
|
||||
DOMAIN: 'lbry.tv',
|
||||
URL: 'https://lbry.tv',
|
||||
SITE_TITLE: 'lbry.tv',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const config = require('../../config');
|
||||
const redirectHosts = ['open.lbry.com'];
|
||||
const PAGES = require('../../ui/constants/pages');
|
||||
|
||||
async function redirectMiddleware(ctx, next) {
|
||||
const requestHost = ctx.host;
|
||||
|
@ -16,8 +16,24 @@ async function redirectMiddleware(ctx, next) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (redirectHosts.includes(requestHost)) {
|
||||
const redirectUrl = config.URL + path;
|
||||
if (requestHost === 'open.lbry.com') {
|
||||
let redirectUrl = config.URL;
|
||||
const openQuery = '?src=open';
|
||||
const matches = /(\/\?)([a-z]*)(.*)/.exec(url);
|
||||
|
||||
if (matches && matches.length) {
|
||||
[, , page, queryString] = matches;
|
||||
|
||||
// This is a lbry app page. Make sure to add the leading `/$/`
|
||||
if (page && Object.values(PAGES).includes(page)) {
|
||||
redirectUrl += '/$/' + page;
|
||||
}
|
||||
|
||||
redirectUrl += openQuery + queryString;
|
||||
} else {
|
||||
redirectUrl += path + openQuery;
|
||||
}
|
||||
|
||||
ctx.redirect(redirectUrl);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
export const AUTH = 'signin';
|
||||
export const AUTH_VERIFY = 'verify';
|
||||
export const BACKUP = 'backup';
|
||||
export const CHANNEL = 'channel';
|
||||
export const DISCOVER = 'discover';
|
||||
export const DOWNLOADED = 'downloaded';
|
||||
export const HELP = 'help';
|
||||
export const LIBRARY = 'library';
|
||||
export const INVITE = 'invite';
|
||||
export const PUBLISH = 'publish';
|
||||
export const PUBLISHED = 'published';
|
||||
export const GET_CREDITS = 'getcredits';
|
||||
export const REPORT = 'report';
|
||||
export const REWARDS = 'rewards';
|
||||
export const SEND = 'send';
|
||||
export const SETTINGS = 'settings';
|
||||
export const SHOW = 'show';
|
||||
export const ACCOUNT = 'account';
|
||||
export const FOLLOWING = 'following';
|
||||
export const SEARCH = 'search';
|
||||
export const TRANSACTIONS = 'transactions';
|
||||
export const TAGS = 'tags';
|
||||
export const WALLET = 'wallet';
|
||||
export const BLOCKED = 'blocked';
|
||||
export const CHANNELS = 'channels';
|
||||
exports.AUTH = 'signin';
|
||||
exports.AUTH_VERIFY = 'verify';
|
||||
exports.BACKUP = 'backup';
|
||||
exports.CHANNEL = 'channel';
|
||||
exports.DISCOVER = 'discover';
|
||||
exports.DOWNLOADED = 'downloaded';
|
||||
exports.HELP = 'help';
|
||||
exports.LIBRARY = 'library';
|
||||
exports.INVITE = 'invite';
|
||||
exports.PUBLISH = 'publish';
|
||||
exports.PUBLISHED = 'published';
|
||||
exports.GET_CREDITS = 'getcredits';
|
||||
exports.REPORT = 'report';
|
||||
exports.REWARDS = 'rewards';
|
||||
exports.SEND = 'send';
|
||||
exports.SETTINGS = 'settings';
|
||||
exports.SHOW = 'show';
|
||||
exports.ACCOUNT = 'account';
|
||||
exports.FOLLOWING = 'following';
|
||||
exports.SEARCH = 'search';
|
||||
exports.TRANSACTIONS = 'transactions';
|
||||
exports.TAGS = 'tags';
|
||||
exports.WALLET = 'wallet';
|
||||
exports.BLOCKED = 'blocked';
|
||||
exports.CHANNELS = 'channels';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'babel-polyfill';
|
||||
|
||||
import ErrorBoundary from 'component/errorBoundary';
|
||||
import App from 'component/app';
|
||||
import SnackBar from 'component/snackBar';
|
||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -8118,10 +8118,10 @@ node-releases@^1.1.38:
|
|||
dependencies:
|
||||
semver "^6.3.0"
|
||||
|
||||
node-sass@^4.11.0:
|
||||
version "4.12.0"
|
||||
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017"
|
||||
integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==
|
||||
node-sass@^4.13.0:
|
||||
version "4.13.0"
|
||||
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.13.0.tgz#b647288babdd6a1cb726de4545516b31f90da066"
|
||||
integrity sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==
|
||||
dependencies:
|
||||
async-foreach "^0.1.3"
|
||||
chalk "^1.1.1"
|
||||
|
@ -8130,7 +8130,7 @@ node-sass@^4.11.0:
|
|||
get-stdin "^4.0.1"
|
||||
glob "^7.0.3"
|
||||
in-publish "^2.0.0"
|
||||
lodash "^4.17.11"
|
||||
lodash "^4.17.15"
|
||||
meow "^3.7.0"
|
||||
mkdirp "^0.5.1"
|
||||
nan "^2.13.2"
|
||||
|
|
Loading…
Add table
Reference in a new issue