Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaustav/test pr 2 #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -7,14 +7,14 @@ i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json

# This directory must match .babelrc .
transifex_temp = ./temp/babel-plugin-react-intl
transifex_temp = ./temp/babel-plugin-formatjs

precommit:
npm run lint
npm audit

requirements:
npm install
npm ci

i18n.extract:
# Pulling display strings from .jsx files into .json files...
Expand Down
1,078 changes: 465 additions & 613 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"build": "fedx-scripts webpack",
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
"i18n_extract": "fedx-scripts formatjs extract",
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
"snapshot": "fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress",
Expand All @@ -33,7 +33,7 @@
},
"dependencies": {
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
"@edx/frontend-platform": "^5.0.0",
"@edx/frontend-platform": "^5.5.4",
"@edx/paragon": "20.46.2",
"@fortawesome/fontawesome-svg-core": "6.4.2",
"@fortawesome/free-brands-svg-icons": "6.4.2",
Expand Down Expand Up @@ -71,7 +71,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "^1.1.1",
"@edx/frontend-build": "12.9.8",
"@edx/frontend-build": "13.0.1",
"@edx/reactifex": "1.1.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"babel-plugin-formatjs": "10.5.3",
Expand Down
4 changes: 1 addition & 3 deletions src/login/LoginPage.jsx
Expand Up @@ -233,9 +233,7 @@ class LoginPage extends React.Component {
return (
<>
<Helmet>
<title>{intl.formatMessage(messages['login.page.title'],
{ siteName: getConfig().SITE_NAME })}
</title>
<title>Get in Page</title>
</Helmet>
<RedirectLogistration
success={this.props.loginResult.success}
Expand Down
4 changes: 2 additions & 2 deletions src/recommendations/ProductCard/BaseCard/index.jsx
Expand Up @@ -39,8 +39,8 @@ const BaseCard = ({
/>
<Card.Header
className="mt-2"
title={truncateText(title)}
subtitle={truncateText(subtitle)}
title={truncateText(title, 50)}
subtitle={truncateText(subtitle, 30)}
/>
<Card.Section className="d-flex">
<div className="product-badge">
Expand Down
4 changes: 3 additions & 1 deletion src/recommendations/data/utils.js
Expand Up @@ -47,7 +47,9 @@ export const getVariant = (productType) => (

export const createCodeFriendlyProduct = (type) => type?.replace(/\s+/g, '-').replace(/'/g, '').toLowerCase();

export const truncateText = (input) => (input?.length > 50 ? `${input.substring(0, 50)}...` : input);
export const truncateText = (input, textLength) => (
input?.length > textLength ? `${input.substring(0, textLength)}...` : input
);

export const filterLocationRestriction = (products, countryCode) => products.filter((product) => {
if (product.locationRestriction) {
Expand Down
12 changes: 9 additions & 3 deletions src/register/RegistrationFields/NameField/validator.js
@@ -1,13 +1,19 @@
import messages from '../../messages';

export const INVALID_NAME_REGEX = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi; // eslint-disable-line no-useless-escape
export const urlRegex = new RegExp(INVALID_NAME_REGEX);
// regex more focused towards url matching
export const URL_REGEX = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi; // eslint-disable-line no-useless-escape

// regex for html tags
export const HTML_REGEX = /<|>/u;

// regex from backend
export const INVALID_NAME_REGEX = /https?:\/\/(?:[-\w.]|(?:%[\da-fA-F]{2}))*/g;

const validateName = (value, formatMessage) => {
let fieldError;
if (!value.trim()) {
fieldError = formatMessage(messages['empty.name.field.error']);
} else if (value && value.match(urlRegex)) {
} else if (URL_REGEX.test(value) || HTML_REGEX.test(value) || INVALID_NAME_REGEX.test(value)) {
fieldError = formatMessage(messages['name.validation.message']);
}
return fieldError;
Expand Down