fix: handle undefined/null input in stripHtmlTags function
All checks were successful
CI / update (push) Successful in 1m19s
All checks were successful
CI / update (push) Successful in 1m19s
Adds null check to prevent crash when recipe name or description fields are undefined.
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
// Function to strip HTML tags from a string
|
// Function to strip HTML tags from a string
|
||||||
import {load} from 'cheerio';
|
import {load} from 'cheerio';
|
||||||
|
|
||||||
export function stripHtmlTags(input: string): string {
|
export function stripHtmlTags(input: string | undefined | null): string {
|
||||||
|
if (!input) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
const $ = load(input.replace(/­/g, ''));
|
const $ = load(input.replace(/­/g, ''));
|
||||||
return $.text();
|
return $.text();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user