@@ -6,23 +6,37 @@ export default class extends Component {
66 constructor ( props ) {
77 super ( props ) ;
88
9- if ( props . source . method === 'POST' ) {
10- const contentType = props . source . headers [ 'Content-Type' ] ;
11- let body = '' ;
12- if ( contentType && contentType . includes ( 'application/x-www-form-urlencoded' ) ) {
13- body = Qs . parse ( props . source . body ) ;
14- } else {
15- console . warn ( '[WebView] Content type is not supported yet, please make a PR!' , contentType ) ;
16- return ;
17- }
9+ const { source } = props ;
10+ if ( source . method ) {
11+ if ( props . newWindow ) {
12+ if ( source . method === 'POST' ) {
13+ const contentType = source . headers [ 'Content-Type' ] ;
14+ let body = '' ;
15+ if ( contentType && contentType . includes ( 'application/x-www-form-urlencoded' ) ) {
16+ body = Qs . parse ( source . body ) ;
17+ } else {
18+ console . warn (
19+ '[WebView] When opening a new window, this content-type is not supported yet, please make a PR!' ,
20+ contentType
21+ ) ;
22+ return ;
23+ }
1824
19- window . open (
20- require ( './postMock.html' ) + '?' +
21- Qs . stringify ( {
22- uri : props . source . uri ,
23- body : JSON . stringify ( body ) ,
24- } )
25- ) ;
25+ window . open (
26+ require ( './postMock.html' ) +
27+ '?' +
28+ Qs . stringify ( {
29+ uri : source . uri ,
30+ body : JSON . stringify ( body ) ,
31+ } )
32+ ) ;
33+ } else {
34+ console . warn (
35+ '[WebView] When opening a new window, this method is not supported yet, please make a PR!' ,
36+ source . method
37+ ) ;
38+ }
39+ }
2640 }
2741 }
2842
@@ -41,7 +55,7 @@ export default class extends Component {
4155 onMessage = nativeEvent => nativeEvent . isTrusted && this . props . onMessage ( { nativeEvent } ) ;
4256
4357 render ( ) {
44- if ( this . props . source . method === 'POST' ) {
58+ if ( this . props . newWindow ) {
4559 return (
4660 < View style = { styles . loadingContainer } >
4761 < ActivityIndicator />
0 commit comments