Last active
November 27, 2019 14:13
-
-
Save nandomoreirame/89f02357184b61994abb66ca14266a1e to your computer and use it in GitHub Desktop.
Add https to image - Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { replaceUrl } from './utils'; | |
export default { | |
computed: { | |
partnerImage() { | |
return replaceUrl(this.item.partner.imageUrl); | |
}, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const replaceUrl = (url = '') => { | |
if (typeof url !== 'string' || url === '') return url; | |
return url.startsWith('//') || url.startsWith('http://') ? `https:${url}` : url; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment