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 <tzarebczan@users.noreply.github.com>
This commit is contained in:
David Granado 2022-01-18 11:09:59 -06:00 committed by GitHub
parent 2eadd986b4
commit 179bd44665
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -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) - 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)) - 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 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)) - Supress erroneous dependency warnings ([#711](https://github.com/OdyseeTeam/odysee-frontend/pull/711))
## [0.51.2] - [2021-08-20] ## [0.51.2] - [2021-08-20]

View file

@ -1,5 +1,8 @@
// Disabled flow in this copy. This copy is for uncompiled web server ES5 require()s. // 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 isProduction = process.env.NODE_ENV === 'production';
const channelNameMinLength = 1; const channelNameMinLength = 1;
const claimIdMaxLength = 40; const claimIdMaxLength = 40;
@ -60,12 +63,13 @@ function parseURI(url, requireProto = false) {
const [ const [
streamNameOrChannelName, streamNameOrChannelName,
primaryModSeparator, primaryModSeparator,
primaryModValue, rawPrimaryModValue,
pathSep, // eslint-disable-line no-unused-vars pathSep, // eslint-disable-line no-unused-vars
possibleStreamName, possibleStreamName,
secondaryModSeparator, secondaryModSeparator,
secondaryModValue, secondaryModValue,
] = rest; ] = rest;
const primaryModValue = rawPrimaryModValue && rawPrimaryModValue.replace(/[^\x00-\x7F]/g, '');
const searchParams = new URLSearchParams(qs || ''); const searchParams = new URLSearchParams(qs || '');
const startTime = searchParams.get('t'); const startTime = searchParams.get('t');
@ -96,7 +100,7 @@ function parseURI(url, requireProto = false) {
if (channelName.length < channelNameMinLength) { if (channelName.length < channelNameMinLength) {
throw new Error( throw new Error(
__(`Channel names must be at least %channelNameMinLength% characters.`, { __(`Channel names must be at least ${channelNameMinLength} characters.`, {
channelNameMinLength, channelNameMinLength,
}) })
); );
@ -145,7 +149,7 @@ function parseURIModifier(modSeperator, modValue) {
if (modSeperator) { if (modSeperator) {
if (!modValue) { 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) { 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]+$/))) { 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]*$/)) { if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {