(content)
| 40 | },[data]); |
| 41 | |
| 42 | const heading2 = (content) =>{ |
| 43 | if (content){ |
| 44 | return (<h2>{content}</h2>) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | function NewlineText(props) { |
| 49 | const text = props.text; |
| 50 | const newText = text.split('\n').map(str => <p className='content'>{str}</p>); |
| 51 | return newText; |
| 52 | } |
| 53 | |
| 54 | const paragraph = (content)=>{ |
| 55 | if (content){ |
| 56 | return (<NewlineText text={content} ></NewlineText>) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | //function to check base64 encoding |
| 61 | const isBase64 = (str) => { |
| 62 | if (str ==='' || str.trim() ===''){ return false; } |
| 63 | try { |
| 64 | return btoa(atob(str)) === str; |
| 65 | } catch (err) { |
| 66 | return false; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | //function to decode base64 |
| 71 | const Base64ToString = (encode) => { |
| 72 | let buff = new Buffer(encode, 'base64'); |
| 73 | let decoded = buff.toString('ascii'); |
| 74 | return decoded; |
| 75 | } |
| 76 | |
| 77 | //function to render encoded image file and https image |
| 78 | const renderBase64Image = (source, alt_text, height, width) => { |
| 79 | if(source.startsWith("https") || source.startsWith("http")){ |
| 80 | return ( |
| 81 | <img src={source} alt={alt_text || "image"} className="list-img" height={height || "400px"} width={width || "650px"}/> |
| 82 | ); |
| 83 | } |
| 84 | else if(isBase64(source)===true){ |
| 85 | const decoded = Base64ToString(source); |
| 86 | const s = `data:image/png;base64,${source}`; |
| 87 | return( |
| 88 | <img src={s} alt={alt_text || "image"} className="list-img" height={height || "400px"} width={width || "650px"}/> |
| 89 | ); |
| 90 | } |
| 91 | } |
nothing calls this directly
no outgoing calls
no test coverage detected