Skip to content

Commit

Permalink
fix: ` in description no longer breaks deviant art posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdicarlo committed Jul 24, 2024
1 parent 83dd58a commit 7d8fd79
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class DeviantArt extends Website {

const csrf = res.body.match(/window.__CSRF_TOKEN__ = '(.*)'/)?.[1];
if (csrf) {
this.getFolders(data._id, status.username);
await this.getFolders(data._id, status.username);
} else {
this.logger.warn('Could not find CSRF token for DeviantArt to retrieve folders.');
}
Expand All @@ -86,7 +86,11 @@ export class DeviantArt extends Website {
try {
const csrf = await this.getCSRF(profileId);
const res = await Http.get<{ results: DeviantArtFolder[] }>(
`${this.BASE_URL}/_puppy/dashared/gallection/folders?offset=0&limit=250&type=gallery&with_all_folder=true&with_permissions=true&username=${username}&da_minor_version=20230710&csrf_token=${csrf}`,
`${
this.BASE_URL
}/_puppy/dashared/gallection/folders?offset=0&limit=250&type=gallery&with_all_folder=true&with_permissions=true&username=${encodeURIComponent(
username,
)}&da_minor_version=20230710&csrf_token=${csrf}`,
profileId,
{
requestOptions: { json: true },
Expand Down Expand Up @@ -170,7 +174,9 @@ export class DeviantArt extends Website {
data.part.accountId,
this.BASE_URL,
`
var blocksFromHTML = Draft.convertFromHTML(\`${data.description || '<div></div>'}\`);
var blocksFromHTML = Draft.convertFromHTML(\`${
data.description.replace(/`/g, '&#96;') || '<div></div>'
}\`);
var x = Draft.ContentState.createFromBlockArray(
blocksFromHTML.contentBlocks,
blocksFromHTML.entityMap,
Expand Down Expand Up @@ -276,7 +282,9 @@ export class DeviantArt extends Website {
data.part.accountId,
this.BASE_URL,
`
var blocksFromHTML = Draft.convertFromHTML(\`${data.description || '<div></div>'}\`);
var blocksFromHTML = Draft.convertFromHTML(\`${
data.description.replace(/`/g, '&#96;') || '<div></div>'
}\`);
var x = Draft.ContentState.createFromBlockArray(
blocksFromHTML.contentBlocks,
blocksFromHTML.entityMap,
Expand Down

0 comments on commit 7d8fd79

Please sign in to comment.