respond to PR feedback
This commit is contained in:
parent
6a69ffe0fb
commit
3a9e215357
3 changed files with 8 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
const PAGES = require('../../ui/constants/pages');
|
const PAGES = require('../../ui/constants/pages');
|
||||||
const { formatCustomUrl } = require('../../ui/util/url');
|
const { formatInAppUrl } = require('../../ui/util/url');
|
||||||
const { parseURI } = require('lbry-redux');
|
const { parseURI } = require('lbry-redux');
|
||||||
|
|
||||||
async function redirectMiddleware(ctx, next) {
|
async function redirectMiddleware(ctx, next) {
|
||||||
|
@ -20,7 +20,7 @@ async function redirectMiddleware(ctx, next) {
|
||||||
|
|
||||||
if (requestHost === 'open.lbry.com' || requestHost === 'open.lbry.io') {
|
if (requestHost === 'open.lbry.com' || requestHost === 'open.lbry.io') {
|
||||||
const openQuery = '?src=open';
|
const openQuery = '?src=open';
|
||||||
let redirectUrl = config.URL + formatCustomUrl(url, openQuery);
|
let redirectUrl = config.URL + formatInAppUrl(url, openQuery);
|
||||||
|
|
||||||
if (redirectUrl.includes('?')) {
|
if (redirectUrl.includes('?')) {
|
||||||
redirectUrl = redirectUrl.replace('?', `${openQuery}&`);
|
redirectUrl = redirectUrl.replace('?', `${openQuery}&`);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import pjson from 'package.json';
|
||||||
import app from './app';
|
import app from './app';
|
||||||
import doLogWarningConsoleMessage from './logWarningConsoleMessage';
|
import doLogWarningConsoleMessage from './logWarningConsoleMessage';
|
||||||
import { ConnectedRouter, push } from 'connected-react-router';
|
import { ConnectedRouter, push } from 'connected-react-router';
|
||||||
import { formatLbryUrlForWeb, formatCustomUrl } from 'util/url';
|
import { formatLbryUrlForWeb, formatInAppUrl } from 'util/url';
|
||||||
import { PersistGate } from 'redux-persist/integration/react';
|
import { PersistGate } from 'redux-persist/integration/react';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
import { getAuthToken, setAuthToken } from 'util/saved-passwords';
|
import { getAuthToken, setAuthToken } from 'util/saved-passwords';
|
||||||
|
@ -167,7 +167,7 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
|
||||||
|
|
||||||
const path = url.slice('lbry://'.length);
|
const path = url.slice('lbry://'.length);
|
||||||
if (path.startsWith('?')) {
|
if (path.startsWith('?')) {
|
||||||
const redirectUrl = formatCustomUrl(path);
|
const redirectUrl = formatInAppUrl(path);
|
||||||
return app.store.dispatch(push(redirectUrl));
|
return app.store.dispatch(push(redirectUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ exports.formatFileSystemPath = path => {
|
||||||
ex: lbry://?rewards
|
ex: lbry://?rewards
|
||||||
ex: open.lbry.com/?rewards
|
ex: open.lbry.com/?rewards
|
||||||
*/
|
*/
|
||||||
exports.formatCustomUrl = path => {
|
exports.formatInAppUrl = path => {
|
||||||
// Determine if we need to add a leading "/$/" for app pages
|
// Determine if we need to add a leading "/$/" for app pages
|
||||||
const APP_PAGE_REGEX = /(\?)([a-z]*)(.*)/;
|
const APP_PAGE_REGEX = /(\?)([a-z]*)(.*)/;
|
||||||
const appPageMatches = APP_PAGE_REGEX.exec(path);
|
const appPageMatches = APP_PAGE_REGEX.exec(path);
|
||||||
|
@ -32,16 +32,10 @@ exports.formatCustomUrl = path => {
|
||||||
let actualUrl = '/$/' + page;
|
let actualUrl = '/$/' + page;
|
||||||
|
|
||||||
if (queryString) {
|
if (queryString) {
|
||||||
if (queryString.startsWith('?')) {
|
actualUrl += `?${queryString.slice(1)}`;
|
||||||
actualUrl += queryString;
|
|
||||||
} else if (queryString.startsWith('&')) {
|
|
||||||
// Replace the leading "&" with a "?" because we must have lost the "?" from the page name
|
|
||||||
// /?rewards&a=b => /$/rewards?a=b
|
|
||||||
actualUrl += `?${queryString.slice(1)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return actualUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return actualUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular claim url
|
// Regular claim url
|
||||||
|
|
Loading…
Add table
Reference in a new issue