From 260ec96edd9fad146ddbbf3be4abcf483d59c501 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 10 Jul 2015 11:36:25 +0800 Subject: [PATCH] Resolve relative urls in window.open, fix #2166 --- atom/renderer/lib/override.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index f87c66037bd4..fad18943e772 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -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.