Skip to content

Commit

Permalink
fix(ios): inverted condition on baseURL construction (#11213)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27396
  • Loading branch information
slash-84 authored and sgtcoolguy committed Oct 21, 2019
1 parent 23318ff commit a59cf84
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ - (void)setHtml_:(id)args
NSString *baseURL = options[@"baseURL"];
NSString *mimeType = options[@"mimeType"];

NSURL *url = [baseURL hasPrefix:@"file:"] ? [NSURL URLWithString:baseURL] : [NSURL fileURLWithPath:baseURL];
NSURL *url = [baseURL hasPrefix:@"file:"] ? [NSURL fileURLWithPath:baseURL] : [NSURL URLWithString:baseURL];

[[self webView] loadData:[content dataUsingEncoding:NSUTF8StringEncoding]
MIMEType:mimeType
Expand Down
33 changes: 33 additions & 0 deletions tests/Resources/ti.ui.webview.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2015-Present by Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');

describe('Titanium.UI.WebView', function () {
it('baseURL should be accessible via window.location', (done) => {
const win = Ti.UI.createWindow();
const baseURL = 'https://www.google.com/';
const webView = Ti.UI.createWebView();
webView.setHtml(
'<html><body></body></html>',
{
baseURL
}
);
webView.addEventListener('load', () => {
webView.evalJS('window.location.href', result => {
should(result).be.eql(baseURL);
win.close();
done();
});
});
win.add(webView);
win.open();
});
});

0 comments on commit a59cf84

Please sign in to comment.