Fix item UIDs with illegal url characters in them by urlescaping them.

Fixes #47.
master
Tom Hacohen 4 years ago
parent c0cc2188c5
commit db2f75ae1f

@ -31,7 +31,7 @@ export function journalView(JournalList: any, JournalItem: any) {
const uid = contact.uid;
this.props.history!.push(
routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid }));
routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: encodeURIComponent(uid) }));
}
public render() {
@ -53,7 +53,7 @@ export function journalView(JournalList: any, JournalItem: any) {
render={({ match }) => {
return (
<JournalItem item={items[`${match.params.journalUid}|${match.params.itemUid}`]} />
<JournalItem item={items[`${match.params.journalUid}|${decodeURIComponent(match.params.itemUid)}`]} />
);
}}
/>

@ -65,7 +65,7 @@ class PimMain extends React.PureComponent<PropsType> {
public eventClicked(event: ICAL.Event) {
// FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
const itemUid = `${(event as any).journalUid}|${encodeURIComponent(event.uid)}`;
this.props.history!.push(
routeResolver.getRoute('pim.events._id', { itemUid }));
@ -73,7 +73,7 @@ class PimMain extends React.PureComponent<PropsType> {
public taskClicked(event: ICAL.Event) {
// FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
const itemUid = `${(event as any).journalUid}|${encodeURIComponent(event.uid)}`;
this.props.history!.push(
routeResolver.getRoute('pim.tasks._id.edit', { itemUid }));
@ -81,7 +81,7 @@ class PimMain extends React.PureComponent<PropsType> {
public contactClicked(contact: ContactType) {
// FIXME:Hack
const itemUid = `${(contact as any).journalUid}|${contact.uid}`;
const itemUid = `${(contact as any).journalUid}|${encodeURIComponent(contact.uid)}`;
this.props.history!.push(
routeResolver.getRoute('pim.contacts._id', { itemUid }));

@ -153,12 +153,14 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Route
path={routeResolver.getRoute(props.routePrefix + '._id.edit')}
exact
render={({ match }) => (
render={({ match }) => {
const itemUid = decodeURIComponent(match.params.itemUid);
return (
<Container style={{ maxWidth: '30rem' }}>
{(match.params.itemUid in props.items) &&
{(itemUid in props.items) &&
<ComponentEdit
initialCollection={(props.items[match.params.itemUid] as any).journalUid}
item={props.items[match.params.itemUid]}
initialCollection={(props.items[itemUid] as any).journalUid}
item={props.items[itemUid]}
collections={props.collections}
onSave={props.onItemSave}
onDelete={props.onItemDelete}
@ -167,7 +169,8 @@ const CollectionRoutes = withStyles(styles)(withRouter(
/>
}
</Container>
)}
);
}}
/>
<Route
path={routeResolver.getRoute(props.routePrefix + '._id.log')}
@ -176,7 +179,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Container>
<ItemChangeLog
syncInfo={props.syncInfo}
paramItemUid={match.params.itemUid}
paramItemUid={decodeURIComponent(match.params.itemUid)}
/>
</Container>
)}
@ -216,7 +219,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
Edit
</Button>
</div>
<ComponentView item={props.items[match.params.itemUid]} />
<ComponentView item={props.items[decodeURIComponent(match.params.itemUid)]} />
</Container>
)}
/>

Loading…
Cancel
Save