Skip to content

Commit

Permalink
Modified toWikiDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
omChauhanDev committed Jan 24, 2024
1 parent 4ee2ecf commit ffe561d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/assets/javascripts/utils/wiki_utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import ArticleUtils from './article_utils';

const toWikiDomain = (wiki) => {
const subdomain = wiki.language;
let url = `${wiki.project}.org`;
if (subdomain) {
url = `${subdomain}.${wiki.project}.org`;
}
return `${url}`;
const language = (wiki.language) ? `${wiki.language}.` : 'www.';
const subdomain = (wiki.project === 'wikisource' && !wiki.language) ? '' : language;
return `${subdomain}${wiki.project}.org`;
};

const formatOption = (wiki) => {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/wiki_utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('url', () => {
project: 'wikipedia'
};
const result = toWikiDomain(wikiData);
expect(result).toStrictEqual('wikipedia.org');
expect(result).toStrictEqual('www.wikipedia.org');
}
);
});
Expand Down

0 comments on commit ffe561d

Please sign in to comment.