Skip to content

Commit

Permalink
Clean invisible chars and adjust "__" for server and client use (#715)
Browse files Browse the repository at this point in the history
* 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 53f63c0.

* 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 <[email protected]>
  • Loading branch information
david0178418 and tzarebczan authored Jan 18, 2022
1 parent 2eadd98 commit 179bd44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 8 additions & 4 deletions web/src/lbryURI.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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) {
Expand All @@ -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]*$/)) {
Expand Down

0 comments on commit 179bd44

Please sign in to comment.