From 179bd446652c27a086e58646b423e4ab4421ce71 Mon Sep 17 00:00:00 2001 From: David Granado Date: Tue, 18 Jan 2022 11:09:59 -0600 Subject: [PATCH] Clean invisible chars and adjust "__" for server and client use (#715) * Rewrite __ to be usable on server side * Add changelog entry * Clean invisible characters from primaryModValue * Revert "Rewrite __ to be usable on server side" This reverts commit 53f63c01f3b56c5530955323612826c0ac5dc5d3. * Make pass-through placeholder for __ fn until it can be adapted for node. * Switch messagages to inline interpolation until i18n done Co-authored-by: Thomas Zarebczan --- CHANGELOG.md | 1 + web/src/lbryURI.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bd3cf82..3e44555c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix playlist preview thumbnail ([#7178](https://github.com/lbryio/lbry-desktop/pull/7178) - Fixed “Your Account” popup on mobile ([#7172](https://github.com/lbryio/lbry-desktop/pull/7172)) - Fix disable-support for comments ([#7245](https://github.com/lbryio/lbry-desktop/pull/7245)) +- Fix issue with extra characters appended to url ([#715](https://github.com/OdyseeTeam/odysee-frontend/pull/715)) - Supress erroneous dependency warnings ([#711](https://github.com/OdyseeTeam/odysee-frontend/pull/711)) ## [0.51.2] - [2021-08-20] diff --git a/web/src/lbryURI.js b/web/src/lbryURI.js index 9f7ee308f..2cab121bc 100644 --- a/web/src/lbryURI.js +++ b/web/src/lbryURI.js @@ -1,5 +1,8 @@ // Disabled flow in this copy. This copy is for uncompiled web server ES5 require()s. +// Placeholder until i18n can be adapted for node usage +const __ = (msg) => msg; + const isProduction = process.env.NODE_ENV === 'production'; const channelNameMinLength = 1; const claimIdMaxLength = 40; @@ -60,12 +63,13 @@ function parseURI(url, requireProto = false) { const [ streamNameOrChannelName, primaryModSeparator, - primaryModValue, + rawPrimaryModValue, pathSep, // eslint-disable-line no-unused-vars possibleStreamName, secondaryModSeparator, secondaryModValue, ] = rest; + const primaryModValue = rawPrimaryModValue && rawPrimaryModValue.replace(/[^\x00-\x7F]/g, ''); const searchParams = new URLSearchParams(qs || ''); const startTime = searchParams.get('t'); @@ -96,7 +100,7 @@ function parseURI(url, requireProto = false) { if (channelName.length < channelNameMinLength) { throw new Error( - __(`Channel names must be at least %channelNameMinLength% characters.`, { + __(`Channel names must be at least ${channelNameMinLength} characters.`, { channelNameMinLength, }) ); @@ -145,7 +149,7 @@ function parseURIModifier(modSeperator, modValue) { if (modSeperator) { if (!modValue) { - throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator })); + throw new Error(__(`No modifier provided after separator ${modSeperator}.`, { modSeperator })); } if (modSeperator === MOD_CLAIM_ID_SEPARATOR || MOD_CLAIM_ID_SEPARATOR_OLD) { @@ -158,7 +162,7 @@ function parseURIModifier(modSeperator, modValue) { } if (claimId && (claimId.length > claimIdMaxLength || !claimId.match(/^[0-9a-f]+$/))) { - throw new Error(__(`Invalid claim ID %claimId%.`, { claimId })); + throw new Error(__(`Invalid claim ID ${claimId}.`, { claimId })); } if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {