respond to PR feedback

This commit is contained in:
Sean Yesmunt 2019-12-03 12:55:29 -05:00
parent 6a69ffe0fb
commit 3a9e215357
3 changed files with 8 additions and 14 deletions

View file

@ -1,6 +1,6 @@
const config = require('../../config');
const PAGES = require('../../ui/constants/pages');
const { formatCustomUrl } = require('../../ui/util/url');
const { formatInAppUrl } = require('../../ui/util/url');
const { parseURI } = require('lbry-redux');
async function redirectMiddleware(ctx, next) {
@ -20,7 +20,7 @@ async function redirectMiddleware(ctx, next) {
if (requestHost === 'open.lbry.com' || requestHost === 'open.lbry.io') {
const openQuery = '?src=open';
let redirectUrl = config.URL + formatCustomUrl(url, openQuery);
let redirectUrl = config.URL + formatInAppUrl(url, openQuery);
if (redirectUrl.includes('?')) {
redirectUrl = redirectUrl.replace('?', `${openQuery}&`);

View file

@ -28,7 +28,7 @@ import pjson from 'package.json';
import app from './app';
import doLogWarningConsoleMessage from './logWarningConsoleMessage';
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 analytics from 'analytics';
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);
if (path.startsWith('?')) {
const redirectUrl = formatCustomUrl(path);
const redirectUrl = formatInAppUrl(path);
return app.store.dispatch(push(redirectUrl));
}

View file

@ -21,7 +21,7 @@ exports.formatFileSystemPath = path => {
ex: lbry://?rewards
ex: open.lbry.com/?rewards
*/
exports.formatCustomUrl = path => {
exports.formatInAppUrl = path => {
// Determine if we need to add a leading "/$/" for app pages
const APP_PAGE_REGEX = /(\?)([a-z]*)(.*)/;
const appPageMatches = APP_PAGE_REGEX.exec(path);
@ -32,16 +32,10 @@ exports.formatCustomUrl = path => {
let actualUrl = '/$/' + page;
if (queryString) {
if (queryString.startsWith('?')) {
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;
actualUrl += `?${queryString.slice(1)}`;
}
return actualUrl;
}
// Regular claim url