Skip to content

Commit

Permalink
refactor: use join-url instead on complicated string template
Browse files Browse the repository at this point in the history
  • Loading branch information
JalilArfaoui committed Mar 15, 2022
1 parent 395d220 commit 4cb74fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 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
10 changes: 7 additions & 3 deletions src/app/profiles/App/pathToContributor.ts
Original file line number Diff line number Diff line change
@@ -1,12 +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 `${getPathPrefix(i18n)}${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 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 4cb74fe

Please sign in to comment.