File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export default {
5
5
// Quite useful if you want to bind a link dynamically and don't want to have it clicked and styled when not bound
6
6
const isExternal = props => ! props . to ||
7
7
props . to . startsWith ( 'http' ) ||
8
+ props . to . startsWith ( '//' ) ||
8
9
props . external
9
10
10
11
return isExternal ( props )
Original file line number Diff line number Diff line change @@ -78,6 +78,28 @@ describe('VueLink', () => {
78
78
79
79
expect ( wrapper . html ( ) ) . toBe ( '<a href="https://example.com/"><div>Hi</div></a>' )
80
80
} )
81
+ it ( 'does trigger external on // link' , ( ) => {
82
+ const wrapper = mount ( VueLink , {
83
+ localVue,
84
+ attachToDocument : true ,
85
+ stubs : {
86
+ RouterLink : RouterLinkStub
87
+ } ,
88
+ context : {
89
+ props : {
90
+ to : '//example.com/'
91
+ }
92
+ } ,
93
+ slots : {
94
+ default : '<div>Hi</div>'
95
+ }
96
+ } )
97
+
98
+ expect ( wrapper . isVueInstance ( ) ) . toBe ( true )
99
+ expect ( wrapper . contains ( RouterLinkStub ) ) . toBe ( false )
100
+
101
+ expect ( wrapper . html ( ) ) . toBe ( '<a href="//example.com/"><div>Hi</div></a>' )
102
+ } )
81
103
it ( 'does trigger external on external prop set' , ( ) => {
82
104
const wrapper = mount ( VueLink , {
83
105
localVue,
You can’t perform that action at this time.
0 commit comments