refactor: ♻️ move filename from url on utils
This commit is contained in:
parent
66b59c52fa
commit
a2c3b389ba
@ -10,11 +10,16 @@
|
||||
</template>
|
||||
{{ title }}
|
||||
</NcButton>
|
||||
<NcButton v-if="url" :download="filename" :href="url" target="_blank">
|
||||
<NcButton
|
||||
v-if="url"
|
||||
:download="filenameFromUrl(url)"
|
||||
:href="url"
|
||||
target="_blank">
|
||||
<template #icon>
|
||||
<DownloadIcon :size="20" />
|
||||
</template>
|
||||
{{ t('repod', 'Download') }} {{ size ? `(${episodeFileSize})` : '' }}
|
||||
{{ t('repod', 'Download') }}
|
||||
{{ size ? `(${humanFileSize(size)})` : '' }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</div>
|
||||
@ -25,6 +30,7 @@ import { NcAvatar, NcButton } from '@nextcloud/vue'
|
||||
import DownloadIcon from 'vue-material-design-icons/Download.vue'
|
||||
import OpenInNewIcon from 'vue-material-design-icons/OpenInNew.vue'
|
||||
import SafeHtml from './SafeHtml.vue'
|
||||
import { filenameFromUrl } from '../../utils/url.js'
|
||||
import { humanFileSize } from '../../utils/size.js'
|
||||
|
||||
export default {
|
||||
@ -66,14 +72,9 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
episodeFileSize() {
|
||||
return humanFileSize(this.size)
|
||||
},
|
||||
filename() {
|
||||
const url = new URL(this.url)
|
||||
return url.pathname.split('/').pop()
|
||||
},
|
||||
methods: {
|
||||
filenameFromUrl,
|
||||
humanFileSize,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -70,7 +70,7 @@
|
||||
</NcActionLink>
|
||||
<NcActionLink
|
||||
v-if="episode.url"
|
||||
:download="filename(episode)"
|
||||
:download="filenameFromUrl(episode.url)"
|
||||
:href="episode.url"
|
||||
:name="t('repod', 'Download')"
|
||||
target="_blank"
|
||||
@ -123,6 +123,7 @@ import {
|
||||
NcModal,
|
||||
NcProgressBar,
|
||||
} from '@nextcloud/vue'
|
||||
import { decodeUrl, filenameFromUrl } from '../../utils/url.js'
|
||||
import {
|
||||
durationToSeconds,
|
||||
formatEpisodeTimestamp,
|
||||
@ -138,7 +139,6 @@ import PlaylistPlayIcon from 'vue-material-design-icons/PlaylistPlay.vue'
|
||||
import PlaylistRemoveIcon from 'vue-material-design-icons/PlaylistRemove.vue'
|
||||
import StopIcon from 'vue-material-design-icons/Stop.vue'
|
||||
import axios from '@nextcloud/axios'
|
||||
import { decodeUrl } from '../../utils/url.js'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { showError } from '../../utils/toast.js'
|
||||
import { usePlayer } from '../../store/player.js'
|
||||
@ -224,10 +224,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapActions(usePlayer, ['load']),
|
||||
filename(episode) {
|
||||
const url = new URL(episode.url)
|
||||
return url.pathname.split('/').pop()
|
||||
},
|
||||
filenameFromUrl,
|
||||
formatLocaleDate,
|
||||
hasEnded(episode) {
|
||||
return (
|
||||
|
@ -1,3 +1,7 @@
|
||||
export const encodeUrl = (url) => encodeURIComponent(btoa(url))
|
||||
export const decodeUrl = (url) => atob(decodeURIComponent(url))
|
||||
export const toUrl = (url) => `/${encodeUrl(url)}`
|
||||
export const filenameFromUrl = (str) => {
|
||||
const url = new URL(str)
|
||||
return url.pathname.split('/').pop()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user