File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 15
15
xmlns =" http://www.w3.org/2000/svg"
16
16
xmlns:xlink =" http://www.w3.org/1999/xlink"
17
17
>
18
- <use v-if =" themeOverrideURL" :href =" `${themeOverrideURL}#${themeId}`" width =" 100%" height =" 100%" />
18
+ <use
19
+ v-if =" themeOverrideURL"
20
+ :href =" normalizePath(`${themeOverrideURL}#${themeId}`)"
21
+ width =" 100%"
22
+ height =" 100%"
23
+ />
19
24
<slot v-else />
20
25
</svg >
21
26
</template >
22
27
23
28
<script >
24
29
import { getSetting } from ' docc-render/utils/theme-settings' ;
30
+ import { normalizePath } from ' docc-render/utils/assets' ;
25
31
26
32
export default {
27
33
name: ' SVGIcon' ,
@@ -35,6 +41,9 @@ export default {
35
41
default: null ,
36
42
},
37
43
},
44
+ methods: {
45
+ normalizePath,
46
+ },
38
47
computed: {
39
48
themeOverrideURL : ({ iconUrl, themeId }) => iconUrl || getSetting ([
40
49
' theme' ,
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ jest.mock('docc-render/utils/theme-settings');
16
16
17
17
getSetting . mockReturnValue ( undefined ) ;
18
18
19
+ const mockBaseUrl = '/developer/' ;
20
+
21
+ jest . mock ( 'docc-render/utils/assets' , ( ) => ( {
22
+ normalizePath : jest . fn ( name => mockBaseUrl + name ) ,
23
+ } ) ) ;
24
+
19
25
const createWrapper = attrs => shallowMount ( SVGIcon , {
20
26
slots : {
21
27
default : '<path d="M8.33"></path>' ,
@@ -46,7 +52,7 @@ describe('SVGIcon', () => {
46
52
expect ( wrapper . find ( 'use' ) . attributes ( ) ) . toEqual ( {
47
53
width : '100%' ,
48
54
height : '100%' ,
49
- href : ' theme/override/path#foo' ,
55
+ href : ` ${ mockBaseUrl } theme/override/path#foo` ,
50
56
} ) ;
51
57
} ) ;
52
58
@@ -62,7 +68,7 @@ describe('SVGIcon', () => {
62
68
expect ( wrapper . find ( 'use' ) . attributes ( ) ) . toEqual ( {
63
69
width : '100%' ,
64
70
height : '100%' ,
65
- href : ' /path/to/new/icon.svg#foo' ,
71
+ href : ` ${ mockBaseUrl } /path/to/new/icon.svg#foo` ,
66
72
} ) ;
67
73
} ) ;
68
74
} ) ;
You can’t perform that action at this time.
0 commit comments