Skip to content

Instantly share code, notes, and snippets.

@nandomoreirame
Last active November 27, 2019 14:13
Show Gist options
  • Save nandomoreirame/89f02357184b61994abb66ca14266a1e to your computer and use it in GitHub Desktop.
Save nandomoreirame/89f02357184b61994abb66ca14266a1e to your computer and use it in GitHub Desktop.
Add https to image - Vue
import { replaceUrl } from './utils';
export default {
computed: {
partnerImage() {
return replaceUrl(this.item.partner.imageUrl);
},
},
};
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