@@ -7,7 +7,7 @@ import { connect, createState } from 'reactive';
77import { Observable } from 'rxjs' ;
88import rels from 'stream-store/rels' ;
99import themes from 'themes' ;
10- import { HalResource , NavigatableProps } from 'types' ;
10+ import { HalResource , HttpResponse , NavigatableProps } from 'types' ;
1111import uriTemplate from 'uri-template' ;
1212import { hal , http , reactJsonTheme } from 'utils' ;
1313
@@ -81,7 +81,7 @@ class JsonViewer extends PureComponent<
8181 ) ;
8282
8383 const responses = await Promise . all (
84- [ ...new Set ( [ pattern , String ( pattern ) . replace ( '-' , '' ) ] ) ] . map ( p =>
84+ [ ...new Set ( [ pattern , String ( pattern ) . replace ( / - / g , '' ) ] ) ] . map ( p =>
8585 http . get ( {
8686 headers : { authorization } ,
8787 link : {
@@ -91,16 +91,26 @@ class JsonViewer extends PureComponent<
9191 ) ,
9292 ) ;
9393
94+ const streams = this . _getStreams ( responses ) ;
95+
9496 this . setState ( {
9597 loading : false ,
96- streams : Object . values (
97- responses . flatMap ( ( { body } ) =>
98- getStreamLinks ( hal . normalizeResource ( body as HalResource ) ) ,
99- ) ,
100- ) ,
98+ streams,
10199 } ) ;
102100 } ;
103101
102+ _getStreams = ( responses : HttpResponse [ ] ) =>
103+ Object . values (
104+ responses
105+ . flatMap ( ( { body } ) =>
106+ getStreamLinks ( hal . normalizeResource ( body as HalResource ) ) ,
107+ )
108+ . map ( ( { _links, ...resource } ) => ( {
109+ ...resource ,
110+ _links : hal . resolveLinks ( '../../' , _links ) ,
111+ } ) ) ,
112+ ) ;
113+
104114 _handlePotentialStreamIdClose = ( ) =>
105115 this . setState ( {
106116 open : false ,
0 commit comments