Skip to content

Commit

Permalink
Merge pull request #1244 from dis-moi/fix/getPathToContributor
Browse files Browse the repository at this point in the history
fix(profiles): getPathToContributor does not include path prefix
  • Loading branch information
JalilArfaoui authored Mar 15, 2022
2 parents bdcfc55 + 4cb74fe commit 9aa91fe
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"i18next": "^19.9.2",
"i18next-browser-languagedetector": "^5.0.1",
"isomorphic-fetch": "^2.2.1",
"join-url": "^2.0.0",
"jsdom": "^15.1.1",
"jsdom-global": "^3.0.2",
"koa": "^2.13.4",
Expand Down
3 changes: 2 additions & 1 deletion src/app/profiles/App/Pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import Profiles from './Profiles';
import Error from './Error';
import Subscriptions from './Subscriptions';
import { getFacet } from '../../../../libs/facets/getFacet';
import { getPathPrefix } from '../../../../libs/facets/getPathPrefix';

const Pages = () => {
useChangeLanguage();
const { t, i18n } = useTranslation();
const prefix = getFacet() === 'lmel' ? '' : `/${i18n.language}`;
const prefix = getPathPrefix(i18n);

return (
<>
Expand Down
11 changes: 8 additions & 3 deletions src/app/profiles/App/pathToContributor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import slugify from 'slugify';
import i18n from 'i18next';
import join from 'join-url';
import { Contributor } from 'libs/domain/contributor';
import { getPathPrefix } from '../../../libs/facets/getPathPrefix';

const pathToContributor = (contributor: Contributor) => {
return `${i18n.t('path.profiles.contributors')}/${contributor.id}/${slugify(
contributor.name
)}`;
return join.pathname(
getPathPrefix(i18n),
i18n.t('path.profiles.contributors'),
contributor.id,
slugify(contributor.name)
);
};

export default pathToContributor;
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ declare module '*.mp4' {
}
// eslint-disable-next-line import/order
declare module 'react-adobe-animate';

declare module 'join-url';
5 changes: 5 additions & 0 deletions src/libs/facets/getPathPrefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { i18n } from 'i18next';
import { getFacet } from './getFacet';

export const getPathPrefix = (i18n: i18n): string =>
getFacet() === 'lmel' ? '' : `/${i18n.language}`;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10923,6 +10923,11 @@ join-component@^1.1.0:
resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5"
integrity sha1-uEF7dQZho5K+4sJTfGiyqdSXfNU=

join-url@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/join-url/-/join-url-2.0.0.tgz#a80b63a58eba5b44abaf793c17c3b5817ef69e1b"
integrity sha1-qAtjpY66W0Srr3k8F8O1gX72nhs=

js-string-escape@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
Expand Down

0 comments on commit 9aa91fe

Please sign in to comment.