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

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

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

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

Loading…
Cancel
Save