Skip to content

Commit 67e55af

Browse files
authored
#2113: Fix - Incorrect url formation on copy resource url in resource grid page (#2115)
1 parent 0c5a4dc commit 67e55af

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

geonode_mapstore_client/client/js/utils/ResourceUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,11 @@ export const getDownloadUrlInfo = (resource) => {
780780
};
781781

782782
export const formatResourceLinkUrl = (resource) => {
783-
let href = window.location.href;
783+
let href = window.location.origin;
784784
if (resource?.uuid) {
785-
href = href.replace(/#.+$/, `uuid/${resource.uuid}`);
785+
href = href + `/catalogue/uuid/${resource.uuid}`;
786786
}
787-
return cleanUrl(href);
787+
return href;
788788
};
789789

790790
export const getCataloguePath = (path = '') => {

geonode_mapstore_client/client/js/utils/__tests__/ResourceUtils-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
getResourceAdditionalProperties,
3535
getDimensions,
3636
canManageResourceSettings,
37-
canAccessPermissions
37+
canAccessPermissions,
38+
formatResourceLinkUrl
3839
} from '../ResourceUtils';
3940

4041
describe('Test Resource Utils', () => {
@@ -1009,4 +1010,8 @@ describe('Test Resource Utils', () => {
10091010
expect(canAccessPermissions({ perms: ['change_resourcebase_permissions'] })).toBeTruthy();
10101011
expect(canAccessPermissions({ perms: ['view_resourcebase'] })).toBeFalsy();
10111012
});
1013+
it('formatResourceLinkUrl', () => {
1014+
expect(formatResourceLinkUrl({ uuid: '123' })).toContain('/catalogue/uuid/123');
1015+
expect(formatResourceLinkUrl({ pk: '123' })).toNotContain('/catalogue/uuid/123');
1016+
});
10121017
});

0 commit comments

Comments
 (0)