changement du fonctionnement des depêches, retours a la ligne
This commit is contained in:
parent
650cd6eab2
commit
624b21554c
|
|
@ -93,11 +93,21 @@ function chargerAlbums() {
|
||||||
async function chargerDepeches() {
|
async function chargerDepeches() {
|
||||||
const feed = document.getElementById('feed');
|
const feed = document.getElementById('feed');
|
||||||
|
|
||||||
|
function escapeHtml(str) {
|
||||||
|
return str
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>');
|
||||||
|
}
|
||||||
|
|
||||||
async function parseTexte(texte) {
|
async function parseTexte(texte) {
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
||||||
const urls = texte.match(urlRegex) || [];
|
const urls = texte.match(urlRegex) || [];
|
||||||
let html = texte.replace(urlRegex, '___URL___');
|
let html = texte.replace(urlRegex, '___URL___');
|
||||||
|
|
||||||
|
// échappe le HTML et convertit les retours à la ligne
|
||||||
|
html = escapeHtml(html).replace(/\n/g, '<br>');
|
||||||
|
|
||||||
const embeds = await Promise.all(urls.map(async url => {
|
const embeds = await Promise.all(urls.map(async url => {
|
||||||
if (url.includes('soundcloud.com')) {
|
if (url.includes('soundcloud.com')) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue