Skip to content

Commit

Permalink
fix(ProseImg): prevent conflict between src and baseURL (#2242)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Aug 23, 2023
1 parent 71ed34f commit 2745604
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/components/Prose/ProseImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script setup lang="ts">
import { withBase } from 'ufo'
import { withTrailingSlash, withLeadingSlash, joinURL } from 'ufo'
import { useRuntimeConfig, computed } from '#imports'
const props = defineProps({
Expand All @@ -27,7 +27,10 @@ const props = defineProps({
const refinedSrc = computed(() => {
if (props.src?.startsWith('/') && !props.src.startsWith('//')) {
return withBase(props.src, useRuntimeConfig().app.baseURL)
const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL))
if (_base !== '/' && !props.src.startsWith(_base)) {
return joinURL(_base, props.src)
}
}
return props.src
})
Expand Down

0 comments on commit 2745604

Please sign in to comment.