diff --git a/lbrytv/middleware/redirect.js b/lbrytv/middleware/redirect.js index 4b4ca0de3..05caa563c 100644 --- a/lbrytv/middleware/redirect.js +++ b/lbrytv/middleware/redirect.js @@ -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}&`); diff --git a/ui/index.jsx b/ui/index.jsx index cc6488602..8547ae903 100644 --- a/ui/index.jsx +++ b/ui/index.jsx @@ -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)); } diff --git a/ui/util/url.js b/ui/util/url.js index 284da46cf..61579aa2f 100644 --- a/ui/util/url.js +++ b/ui/util/url.js @@ -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