]> khamidou — GitHub mirrors - electron.git/commitdiff
Resolve relative urls in window.open, fix #2166
authorCheng Zhao <zcbenz@gmail.com>
Fri, 10 Jul 2015 03:36:25 +0000 (11:36 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 10 Jul 2015 03:36:41 +0000 (11:36 +0800)
atom/renderer/lib/override.coffee

index f87c66037bd478aaa3cf81657e581316938cb136..fad18943e7725b67893a22b49f2e6624cc2b3098 100644 (file)
@@ -2,6 +2,12 @@ process = global.process
 ipc = require 'ipc'
 remote = require 'remote'
 
+# Helper function to resolve relative url.
+a = document.createElement 'a'
+resolveUrl = (url) ->
+  a.href = url
+  a.href
+
 # Window object returned by "window.open".
 class BrowserWindowProxy
   constructor: (@guestId) ->
@@ -49,6 +55,9 @@ window.open = (url, frameName='', features='') ->
   options.width ?= 800
   options.height ?= 600
 
+  # Resolve relative urls.
+  url = resolveUrl url
+
   (options[name] = parseInt(options[name], 10) if options[name]?) for name in ints
 
   # Inherit the node-integration option of current window.