Commit 10c1e6c9 authored by Saturnino Abril's avatar Saturnino Abril Committed by Dean Whillier
Browse files

fix undefined site URL when copying permalink (#785)

parent 3cfc42ce
......@@ -5,7 +5,7 @@ import {createSelector} from 'reselect';
import {General} from 'constants';
import {getCurrentUrl} from 'selectors/entities/general';
import {getConfig, getCurrentUrl} from 'selectors/entities/general';
import {createIdsSelector} from 'utils/helpers';
import {isTeamAdmin} from 'utils/user_utils';
......@@ -80,8 +80,9 @@ export const isCurrentUserCurrentTeamAdmin = createSelector(
export const getCurrentTeamUrl = createSelector(
getCurrentUrl,
getCurrentTeam,
(currentUrl, currentTeam) => {
return `${currentUrl}/${currentTeam.name}`;
(state) => getConfig(state).SiteURL,
(currentURL, currentTeam, siteURL) => {
return `${currentURL || siteURL}/${currentTeam.name}`;
}
);
......
......@@ -22,6 +22,7 @@ describe('Selectors.Teams', () => {
teams[team4.id] = team4;
teams[team5.id] = team5;
team1.display_name = 'Marketeam';
team1.name = 'marketing_team';
team2.display_name = 'Core Team';
team3.allow_open_invite = true;
team4.allow_open_invite = true;
......@@ -260,4 +261,35 @@ describe('Selectors.Teams', () => {
assert.deepEqual(Selectors.getCurrentRelativeTeamUrl(testState), '/' + team1.name);
assert.deepEqual(Selectors.getCurrentRelativeTeamUrl({entities: {teams: {teams: {}}}}), '/');
});
it('getCurrentTeamUrl', () => {
const siteURL = 'http://localhost:8065';
const general = {
config: {SiteURL: siteURL},
credentials: {},
};
const withSiteURLState = {
...testState,
entities: {
...testState.entities,
general,
},
};
withSiteURLState.entities.general = general;
assert.deepEqual(Selectors.getCurrentTeamUrl(withSiteURLState), siteURL + '/' + team1.name);
const credentialURL = 'http://localhost';
const withCredentialURLState = {
...withSiteURLState,
entities: {
...withSiteURLState.entities,
general: {
...withSiteURLState.entities.general,
credentials: {url: credentialURL},
},
},
};
assert.deepEqual(Selectors.getCurrentTeamUrl(withCredentialURLState), credentialURL + '/' + team1.name);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment