From 36181e3f7e21d01a417ec47d0e2afaed27c99d73 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Tue, 25 Aug 2020 15:08:42 +0200 Subject: [PATCH] fix(PublicPage): do not parse url and add parse step to address --- src/controllers/PublicController.ts | 78 +++++++++++++++-------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts index fab8439..ca8cdde 100644 --- a/src/controllers/PublicController.ts +++ b/src/controllers/PublicController.ts @@ -138,7 +138,7 @@ export default class PublicController { version.contacts.email = offuscate(version.contacts.email) } 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')) { //let formated: any = formatPhone(version.contacts.phone) @@ -154,42 +154,46 @@ export default class PublicController { return p }) } - if (Utils.isStrUsable(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) - version.contacts.websiteLabel = url.hostname + (url.pathname === '/' ? '' : url.pathname) - } catch (err) { - console.error(err) - version.contacts.website = version.contacts.websiteLabel = "OULA, c'est pas bon :(" - } - } - if (Utils.isStrUsable(version.contacts, 'facebook')) { - try { - version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '') - } catch (err) { - console.error(err) - version.contacts.facebook = version.contacts.facebookLabel = "OULA, c'est pas bon :(" - } - } - if (Utils.isStrUsable(version.contacts, 'twitter')) { - try { - version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '') - } catch (err) { - console.error(err) - version.contacts.twitter = version.contacts.twitterLabel = "OULA, c'est pas bon :(" - } - } - if (Utils.isStrUsable(version.contacts, 'instagram')) { - 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 :(" - } - } + // if (Utils.isStrUsable(version.contacts, 'website')) { + // console.log(version.contacts.website) + // if (version.contacts.website.indexOf('https://') === -1 || version.contacts.website.indexOf('https://') === -1) { + // version.contacts.website = 'http://' + version.contacts.website + // } + // try { + // console.log(version.contacts.website.length) + // let url = new URL(version.contacts.website) + // version.contacts.websiteLabel = url.hostname + url.pathname + // console.log(url.pathname) + // } catch (err) { + // console.error(err) + // version.contacts.website = version.contacts.websiteLabel = "OULA, c'est pas bon :(" + // } + // console.log(version.contacts.websiteLabel) + // } + // if (Utils.isStrUsable(version.contacts, 'facebook')) { + // try { + // version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '') + // } catch (err) { + // console.error(err) + // version.contacts.facebook = version.contacts.facebookLabel = "OULA, c'est pas bon :(" + // } + // } + // if (Utils.isStrUsable(version.contacts, 'twitter')) { + // try { + // version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '') + // } catch (err) { + // console.error(err) + // version.contacts.twitter = version.contacts.twitterLabel = "OULA, c'est pas bon :(" + // } + // } + // if (Utils.isStrUsable(version.contacts, 'instagram')) { + // 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 :(" + // } + // } } /**