This commit is contained in:
Thibault Malbranche 2018-10-13 00:40:20 +02:00
parent d3747b6623
commit 0e34982477
3 changed files with 10 additions and 11 deletions

View File

@ -518,7 +518,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
}
if (source.hasKey("method")) {
String method = source.getString("method");
if (method.equals(HTTP_METHOD_POST)) {
if (method.equalsIgnoreCase(HTTP_METHOD_POST)) {
byte[] postData = null;
if (source.hasKey("body")) {
String body = source.getString("body");

View File

@ -8,11 +8,7 @@
* @flow
*/
'use strict';
import React from 'react';
import ReactNative from 'react-native'
import {
ActivityIndicator,
Linking,
@ -22,7 +18,8 @@ import {
View,
requireNativeComponent,
NativeModules,
Image
Image,
findNodeHandle,
} from 'react-native';
import invariant from 'fbjs/lib/invariant';
@ -136,7 +133,9 @@ class WebView extends React.Component<WebViewSharedProps, State> {
};
state = {
viewState: this.props.startInLoadingState ? WebViewState.LOADING : WebViewState.IDLE,
viewState: this.props.startInLoadingState
? WebViewState.LOADING
: WebViewState.IDLE,
lastErrorEvent: null,
};
@ -203,7 +202,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
'about:blank',
...(this.props.originWhitelist || []),
].map(WebViewShared.originWhitelistToRegex);
const onShouldStartLoadWithRequest = (event) => {
const onShouldStartLoadWithRequest = event => {
let shouldStart = true;
const { url } = event.nativeEvent;
const origin = WebViewShared.extractOrigin(url);
@ -384,7 +383,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
* Returns the native `WebView` node.
*/
getWebViewHandle = () => {
return ReactNative.findNodeHandle(this.webViewRef.current);
return findNodeHandle(this.webViewRef.current);
};
_onLoadingStart = (event: WebViewNavigationEvent) => {

View File

@ -14,11 +14,11 @@ const escapeStringRegexp = require('escape-string-regexp');
const WebViewShared = {
defaultOriginWhitelist: ['http://*', 'https://*'],
extractOrigin: (url: string) => {
extractOrigin: (url: string): string => {
const result = /^[A-Za-z0-9]+:(\/\/)?[^/]*/.exec(url);
return result === null ? '' : result[0];
},
originWhitelistToRegex: (originWhitelist: string) => {
originWhitelistToRegex: (originWhitelist: string): string => {
return escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*');
},
};