Changeset 546
- Timestamp:
- 11/27/13 16:23:34 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r545 r546 284 284 } 285 285 286 public void navigate(final String url) { 287 System.out.println(url); 286 public void navigate(String url) { 287 final String actualURL; 288 String urlLower = url.toLowerCase(); 289 // check if protocol is missing 290 // TODO: can/should we support other protocols such as ftp ??? 291 if(!(urlLower.startsWith("http://") || url.startsWith("https://"))) { 292 // check if it's a search 293 int firstSpace = url.indexOf(" "); 294 int firstDot = url.indexOf("."); 295 int firstSlash = url.indexOf('/'); 296 int firstQuestion = url.indexOf('?'); 297 if(firstDot == -1 || // no '.' and no protocol -> search 298 (firstSpace != -1 && firstSpace <= firstDot + 1) || // ' ' before '.' -> search 299 (firstSlash == -1 && firstQuestion == -1)) { // no '/' or '?' -> search 300 // make it a search 301 actualURL = UserSettings.searchEngine + url; 302 } else { 303 // add the missing protocol 304 actualURL = "http://" + url; 305 } 306 } else { 307 actualURL = url; 308 } 309 System.out.println(actualURL); 288 310 try { 289 311 PlatformRunLater.invoke(null, new Runnable() { … … 291 313 public void run() { 292 314 try { 293 WebEngineLoad.invoke(WebViewGetEngine.invoke(JfxBrowser.this._browser.webview), url);315 WebEngineLoad.invoke(WebViewGetEngine.invoke(JfxBrowser.this._browser.webview), actualURL); 294 316 } catch (Exception e) { 295 317 e.printStackTrace(); … … 307 329 if ((carried = FreeItems.getTextAttachedToCursor()) != null) { 308 330 String text = carried.getText().trim(); 309 String textLower = text.toLowerCase();310 // check if protocol is missing311 // TODO: can/should we support other protocols such as ftp ???312 if(!(textLower.startsWith("http://") || text.startsWith("https://"))) {313 // check if it's a search314 int firstSpace = text.indexOf(" ");315 int firstDot = text.indexOf(".");316 int firstSlash = text.indexOf('/');317 int firstQuestion = text.indexOf('?');318 if(firstDot == -1 || // no '.' and no protocol -> search319 (firstSpace != -1 && firstSpace <= firstDot + 1) || // ' ' before '.' -> search320 (firstSlash == -1 && firstQuestion == -1)) { // no '/' or '?' -> search321 // make it a search322 text = UserSettings.searchEngine + text;323 } else {324 // add the missing protocol325 text = "http://" + text;326 }327 }328 331 this.navigate(text); 329 332 FreeItems.getInstance().clear();
Note:
See TracChangeset
for help on using the changeset viewer.