fix(PublicPage): do not parse url and add parse step to address

This commit is contained in:
Matthieu Bessat 2020-08-25 15:08:42 +02:00
parent efcff86164
commit 36181e3f7e

View file

@ -138,7 +138,7 @@ export default class PublicController {
version.contacts.email = offuscate(version.contacts.email) version.contacts.email = offuscate(version.contacts.email)
} }
if (Utils.isStrUsable(version.contacts, 'address')) { if (Utils.isStrUsable(version.contacts, 'address')) {
version.contacts.address = version.contacts.address.split('\n') version.contacts.address = version.contacts.address.replace('%postalsep%', ' ').split('\n')
} }
if (Utils.isStrUsable(version.contacts, 'phone')) { if (Utils.isStrUsable(version.contacts, 'phone')) {
//let formated: any = formatPhone(version.contacts.phone) //let formated: any = formatPhone(version.contacts.phone)
@ -154,42 +154,46 @@ export default class PublicController {
return p return p
}) })
} }
if (Utils.isStrUsable(version.contacts, 'website')) { // if (Utils.isStrUsable(version.contacts, 'website')) {
if (version.contacts.website.indexOf('https://') === -1 || version.contacts.website.indexOf('https://') === -1) { // console.log(version.contacts.website)
version.contacts.website = 'http://' + version.contacts.website // if (version.contacts.website.indexOf('https://') === -1 || version.contacts.website.indexOf('https://') === -1) {
} // version.contacts.website = 'http://' + version.contacts.website
try { // }
let url = new URL(version.contacts.website) // try {
version.contacts.websiteLabel = url.hostname + (url.pathname === '/' ? '' : url.pathname) // console.log(version.contacts.website.length)
} catch (err) { // let url = new URL(version.contacts.website)
console.error(err) // version.contacts.websiteLabel = url.hostname + url.pathname
version.contacts.website = version.contacts.websiteLabel = "OULA, c'est pas bon :(" // console.log(url.pathname)
} // } catch (err) {
} // console.error(err)
if (Utils.isStrUsable(version.contacts, 'facebook')) { // version.contacts.website = version.contacts.websiteLabel = "OULA, c'est pas bon :("
try { // }
version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '') // console.log(version.contacts.websiteLabel)
} catch (err) { // }
console.error(err) // if (Utils.isStrUsable(version.contacts, 'facebook')) {
version.contacts.facebook = version.contacts.facebookLabel = "OULA, c'est pas bon :(" // try {
} // version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '')
} // } catch (err) {
if (Utils.isStrUsable(version.contacts, 'twitter')) { // console.error(err)
try { // version.contacts.facebook = version.contacts.facebookLabel = "OULA, c'est pas bon :("
version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '') // }
} catch (err) { // }
console.error(err) // if (Utils.isStrUsable(version.contacts, 'twitter')) {
version.contacts.twitter = version.contacts.twitterLabel = "OULA, c'est pas bon :(" // try {
} // version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '')
} // } catch (err) {
if (Utils.isStrUsable(version.contacts, 'instagram')) { // console.error(err)
try { // version.contacts.twitter = version.contacts.twitterLabel = "OULA, c'est pas bon :("
version.contacts.instagramLabel = new URL(version.contacts.instagram).pathname.replace('/', '') // }
} catch (err) { // }
console.error(err) // if (Utils.isStrUsable(version.contacts, 'instagram')) {
version.contacts.instagram = version.contacts.instagramLabel = "OULA, c'est pas bon :(" // try {
} // version.contacts.instagramLabel = new URL(version.contacts.instagram).pathname.replace('/', '')
} // } catch (err) {
// console.error(err)
// version.contacts.instagram = version.contacts.instagramLabel = "OULA, c'est pas bon :("
// }
// }
} }
/** /**