Skip to content

Commit 563b7c8

Browse files
committed
fix(Bandcamp): Properly serialize additional strings for embedded JSON
https://ibelieveinangels.bandcamp.com/track/salvation uses backslashes in its og:description that have to be escaped: > Bad escaped character in JSON at position 2812 (line 1 column 2813)
1 parent c237c6e commit 563b7c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

providers/Bandcamp/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ export default class BandcampProvider extends MetadataProvider {
171171

172172
const description = extractMetadataTag(html, 'og:description');
173173
if (description) {
174-
jsonEntries.push(['og:description', `"${description}"`]);
174+
jsonEntries.push(['og:description', JSON.stringify(description)]);
175175
}
176176

177177
const licenseUrl = extractTextFromHtml(html, /class="cc-icons"\s+href="([^"]+)"/i);
178178
if (licenseUrl) {
179-
jsonEntries.push(['licenseUrl', `"${licenseUrl}"`]);
179+
jsonEntries.push(['licenseUrl', JSON.stringify(licenseUrl)]);
180180
}
181181

182182
const json = `{${jsonEntries.map(([key, serializedValue]) => `"${key}":${serializedValue}`).join(',')}}`;

0 commit comments

Comments
 (0)