Skip to content

Commit 8af4387

Browse files
Merge pull request #1351 from geonetwork/backport/2.6.x/pr-1319
[2.6.x] [Datahub]: Fix organizations with slash (#1319)
2 parents 88bf972 + fc6e88e commit 8af4387

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

apps/datahub/src/app/organization/organization-page/organization-page.component.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,23 @@ describe('OrganizationPageComponent', () => {
6464
expect(org).toBe(expectedOrganization)
6565
})
6666
})
67+
it('should match orgs with a slash', () => {
68+
const orgWithSlash = {
69+
...expectedOrganization,
70+
name: 'org/withslash',
71+
}
72+
73+
const orgService = TestBed.inject(OrganizationsServiceInterface) as any
74+
orgService.organisations$ = of([orgWithSlash])
75+
76+
const router = TestBed.inject(RouterFacade) as any
77+
router.pathParams$ = of({ name: 'orgwithslash' })
78+
79+
component.ngOnInit()
80+
81+
component.organization$.subscribe((org) => {
82+
expect(org).toEqual(orgWithSlash)
83+
})
84+
})
6785
})
6886
})

apps/datahub/src/app/organization/organization-page/organization-page.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export class OrganizationPageComponent implements OnInit {
4040
filter(([pathParams, _]) => Object.keys(pathParams).length > 0),
4141
switchMap(([pathParams, organizations]) => {
4242
const organization = organizations.find(
43-
(organization) => organization.name === pathParams['name']
43+
(organization) =>
44+
organization.name.replace('/', '') === pathParams['name']
4445
)
4546
return of(organization)
4647
})

libs/feature/router/src/lib/default/state/router.facade.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export class RouterFacade {
6363
}
6464

6565
goToOrganization(organizationName: string) {
66-
const path = `${this.routerService.getOrganizationPageRoute()}/${organizationName}`
66+
const safeOrgName = organizationName.replace('/', '')
67+
const path = `${this.routerService.getOrganizationPageRoute()}/${safeOrgName}`
6768
this.go({
6869
path,
6970
queryParamsHandling: '',

0 commit comments

Comments
 (0)