mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Improved null url handling
Summary: public Attempting to load an undefined URL via XMLHttpRequest produced a confusing error deep within the network layer. This diff improves the networking stack to catch such errors earlier, and also adds a helpful error in the JS layer. Fixes https://github.com/facebook/react-native/issues/4558 Reviewed By: javache Differential Revision: D2811080 fb-gh-sync-id: 1837427e1080a0308f2c4f9a8a42bce2e041fb48
This commit is contained in:
committed by
facebook-github-bot-8
parent
57f6cbb3dc
commit
571e646543
@@ -136,6 +136,10 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (id<RCTURLRequestHandler>)handlerForRequest:(NSURLRequest *)request
|
||||
{
|
||||
if (!request.URL) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (!_handlers) {
|
||||
|
||||
// get handlers
|
||||
|
||||
@@ -179,6 +179,9 @@ class XMLHttpRequestBase {
|
||||
// async is default
|
||||
throw new Error('Synchronous http requests are not supported');
|
||||
}
|
||||
if (!url) {
|
||||
throw new Error('Cannot load an empty url');
|
||||
}
|
||||
this._reset();
|
||||
this._method = method;
|
||||
this._url = url;
|
||||
|
||||
Reference in New Issue
Block a user