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 1515 xmlns =" http://www.w3.org/2000/svg"
1616 xmlns:xlink =" http://www.w3.org/1999/xlink"
1717 >
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+ />
1924 <slot v-else />
2025 </svg >
2126</template >
2227
2328<script >
2429import { getSetting } from ' docc-render/utils/theme-settings' ;
30+ import { normalizePath } from ' docc-render/utils/assets' ;
2531
2632export default {
2733 name: ' SVGIcon' ,
@@ -35,6 +41,9 @@ export default {
3541 default: null ,
3642 },
3743 },
44+ methods: {
45+ normalizePath,
46+ },
3847 computed: {
3948 themeOverrideURL : ({ iconUrl, themeId }) => iconUrl || getSetting ([
4049 ' theme' ,
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ jest.mock('docc-render/utils/theme-settings');
1616
1717getSetting . mockReturnValue ( undefined ) ;
1818
19+ const mockBaseUrl = '/developer/' ;
20+
21+ jest . mock ( 'docc-render/utils/assets' , ( ) => ( {
22+ normalizePath : jest . fn ( name => mockBaseUrl + name ) ,
23+ } ) ) ;
24+
1925const createWrapper = attrs => shallowMount ( SVGIcon , {
2026 slots : {
2127 default : '<path d="M8.33"></path>' ,
@@ -46,7 +52,7 @@ describe('SVGIcon', () => {
4652 expect ( wrapper . find ( 'use' ) . attributes ( ) ) . toEqual ( {
4753 width : '100%' ,
4854 height : '100%' ,
49- href : ' theme/override/path#foo' ,
55+ href : ` ${ mockBaseUrl } theme/override/path#foo` ,
5056 } ) ;
5157 } ) ;
5258
@@ -62,7 +68,7 @@ describe('SVGIcon', () => {
6268 expect ( wrapper . find ( 'use' ) . attributes ( ) ) . toEqual ( {
6369 width : '100%' ,
6470 height : '100%' ,
65- href : ' /path/to/new/icon.svg#foo' ,
71+ href : ` ${ mockBaseUrl } /path/to/new/icon.svg#foo` ,
6672 } ) ;
6773 } ) ;
6874} ) ;
You can’t perform that action at this time.
0 commit comments