Skip to content

Commit

Permalink
fix(android): handle encoded WebView url (#12463)
Browse files Browse the repository at this point in the history
  • Loading branch information
build authored Feb 10, 2021
1 parent 7b26838 commit f5f8f67
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ public void setUrl(String url)
final Uri uri = Uri.parse(url);

// Extract URL query parameters.
final String query = uri.getQuery() != null ? "?" + uri.getQuery() : "";
final String encodedQuery = uri.getEncodedQuery();
final String query = encodedQuery != null ? "?" + encodedQuery : "";
final String fragment = uri.getFragment();

// Resolve URL path.
Expand Down
42 changes: 42 additions & 0 deletions tests/Resources/ti.ui.webview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,48 @@ describe('Titanium.UI.WebView', function () {
win.open();
});

it('decode url', (finish) => {
win = Ti.UI.createWindow({
backgroundColor: 'blue'
});
const webview = Ti.UI.createWebView({
url: 'https://www.google.com/sub/api?key=TiTeSTKEy%3D%3D&var=1234'
});

webview.addEventListener('load', e => {
try {
should(e.source.url).be.a.String();
should(e.source.url).eql('https://www.google.com/sub/api?key=TiTeSTKEy%3D%3D&var=1234');
} catch (err) {
return finish(err);
}
finish();
});
win.add(webview);
win.open();
});

it('decode \'+\' in url', (finish) => {
win = Ti.UI.createWindow({
backgroundColor: 'blue'
});
const webview = Ti.UI.createWebView({
url: 'https://www.google.com/pin%20wheel+.jpg'
});

webview.addEventListener('load', e => {
try {
should(e.source.url).be.a.String();
should(e.source.url).eql('https://www.google.com/pin%20wheel+.jpg');
} catch (err) {
return finish(err);
}
finish();
});
win.add(webview);
win.open();
});

describe.ios('#findString()', function () {
it('is a Function', () => {
if (OS_VERSION_MAJOR < 14) {
Expand Down

0 comments on commit f5f8f67

Please sign in to comment.