git ssb

16+

Dominic / patchbay



Commit 2a990899321f909f52dce13715ee580d1e8507b6

correctly detect internal and external links

Dominic Tarr committed on 7/20/2016, 2:04:04 AM
Parent: eeaba82cd174ef3af7ffc6f6bc0aa88d92a5c6ec

Files changed

modules/tabs.jschanged
modules/tabs.jsView
@@ -2,8 +2,9 @@
22 var h = require('hyperscript')
33 var pull = require('pull-stream')
44 var u = require('../util')
55 var keyscroll = require('../keyscroll')
6+var open = require('open-external')
67
78 function ancestor (el) {
89 if(!el) return
910 if(el.tagName !== 'A') return ancestor(el.parentElement)
@@ -13,23 +14,8 @@
1314 var plugs = require('../plugs')
1415 var screen_view = plugs.first(exports.screen_view = [])
1516 var search_box = plugs.first(exports.search_box = [])
1617
17-function openExternal (url) {
18- var _r = require //fool browserify
19-
20- //electron@1
21- try {return _r('electron').shell.openExternal(url) }
22- catch (err) { }
23-
24- //electron@0
25- try { return _r('shell').openExternal(url) }
26- catch (err) { }
27-
28- //browser
29- window.open(url, '_blank')
30-}
31-
3218 exports.message_render = []
3319
3420 exports.app = function () {
3521 var search
@@ -80,9 +66,9 @@
8066 ev.stopPropagation()
8167
8268 //open external links.
8369 //this ought to be made into something more runcible
84- if(/^https?/.test(link.href)) return openExternal(link.href)
70+ if(open.isExternal(link.href)) return open(link.href)
8571
8672 if(tabs.has(path)) return tabs.select(path)
8773
8874 var el = screen_view(path)
@@ -165,6 +151,4 @@
165151
166152 return tabs
167153 }
168154
169-
170-

Built with git-ssb-web