Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed May 4, 2019
1 parent 33d78ac commit d9b89b9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
19 changes: 10 additions & 9 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page">
<ScrollView>
<StackLayout class="p-20">
<ScrollView>
<StackLayout class="p-20">

<!--<Label text="Default headers, according to https://httpbin.org/headers:" class="t-20 text-center c-black" textWrap="true"/>-->
<!--<WebView height="320" src="https://httpbin.org/headers?wv=1"/>-->
<Label text="GET with custom headers:" class="t-20 text-center c-black" textWrap="true"/>
<WebView loaded="webViewLoaded" loadStarted="webViewLoadStarted" loadFinished="webViewLoadFinished"
height="250" src="https://httpbin.org/headers?wv=2"/>

<Label text="And now with custom headers:" class="t-20 text-center c-black" textWrap="true"/>
<WebView loaded="webViewLoaded" loadStarted="webViewLoadStarted" loadFinished="webViewLoadFinished" height="370" src="https://httpbin.org/headers?wv=2"/>
<!--<WebView loaded="webViewLoaded" loadStarted="webViewLoadStarted" loadFinished="webViewLoadFinished" height="370" src="<p>Hi</p>"/>-->
<Label text="A form that will POST:" class="t-20 text-center c-black" textWrap="true"/>
<WebView loaded="webViewLoaded" loadStarted="webViewLoadStarted" loadFinished="webViewLoadFinished"
height="500" src="https://httpbin.org/forms/post"/>

</StackLayout>
</ScrollView>
</StackLayout>
</ScrollView>
</Page>
12 changes: 6 additions & 6 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"nativescript": {
"id": "org.nativescript.demo",
"tns-ios": {
"version": "3.4.1"
"version": "5.3.1"
},
"tns-android": {
"version": "3.4.1"
"version": "5.3.1"
}
},
"dependencies": {
"nativescript-theme-core": "^1.0.4",
"nativescript-unit-test-runner": "^0.3.4",
"nativescript-webview-utils": "../src",
"tns-core-modules": "~3.4.0"
"nativescript-webview-utils": "file:../src",
"tns-core-modules": "~5.3.1"
},
"devDependencies": {
"@types/jasmine": "~2.8.6",
Expand All @@ -33,8 +33,8 @@
"nativescript-dev-webpack": "~0.9.0",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.1.0",
"tns-platform-declarations": "~3.4.0",
"typescript": "~2.6.0",
"tns-platform-declarations": "~5.3.1",
"typescript": "~2.8.0",
"webpack": "~3.8.1",
"webpack-bundle-analyzer": "^2.8.2",
"webpack-sources": "~1.0.1",
Expand Down
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "npm i && tsc",
"demo.ios": "npm run preparedemo && cd ../demo && tns run ios --emulator",
"demo.ios.device": "npm run preparedemo && cd ../demo && tns platform remove ios && tns run ios",
"demo.android": "npm run preparedemo && cd ../demo && tns platform remove android && tns run android --justlaunch",
"demo.android": "npm run preparedemo && cd ../demo && tns platform remove android && tns run android",
"test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns build android",
"test.ios": "cd ../demo && tns platform remove ios && tns test ios --emulator",
"test.ios.device": "cd ../demo && tns platform remove ios && tns test ios",
Expand Down Expand Up @@ -49,9 +49,9 @@
"homepage": "https://github.com/EddyVerbruggen/nativescript-webview-utils",
"readmeFilename": "README.md",
"devDependencies": {
"tns-core-modules": "~3.4.0",
"tns-platform-declarations": "~3.4.0",
"typescript": "~2.6.0",
"tns-core-modules": "~5.3.1",
"tns-platform-declarations": "~5.3.1",
"typescript": "~2.8.0",
"tslint": "^5.0.0"
},
"dependencies": {},
Expand Down
2 changes: 1 addition & 1 deletion src/webview-utils.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class WebViewUtils extends android.webkit.WebViewClient {
let request: any = arguments[1];
let error: any = arguments[2];

super.onReceivedError(view, request, error);
super.onReceivedError(view, request, error, undefined);

const headersAdded = error.getUrl && this.headersAddedTo.has(error.getUrl());
if (headersAdded && WebViewUtils.wv) {
Expand Down
5 changes: 3 additions & 2 deletions src/webview-utils.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class WebviewUtilsWKNavigationDelegateImpl extends NSObject implements WKNavigat
handler.headers = headers;
return handler;
}

private _owner: WeakRef<WebView>;

webViewDecidePolicyForNavigationActionDecisionHandler(webView: WKWebView, navigationAction: WKNavigationAction, decisionHandler: (p1: WKNavigationActionPolicy) => void): void {
Expand All @@ -27,13 +28,13 @@ class WebviewUtilsWKNavigationDelegateImpl extends NSObject implements WKNavigat
});

if (isHttpRequest && !areHeadersAdded) {
if (navigationAction.request.HTTPMethod !== 'GET') {
if (navigationAction.request.HTTPMethod !== "GET") {
decisionHandler(WKNavigationActionPolicy.Allow);
return;
}

decisionHandler(WKNavigationActionPolicy.Cancel);

const customRequest = navigationAction.request.mutableCopy();

// add the original headers
Expand Down

0 comments on commit d9b89b9

Please sign in to comment.