util.js 498 B

1234567891011121314151617
  1. export function stripScript(content) {
  2. const result = content.match(/<(script)>([\s\S]+)<\/\1>/);
  3. return result && result[2] ? result[2].trim() : '';
  4. }
  5. export function stripStyle(content) {
  6. const result = content.match(/<(style)\s*>([\s\S]+)<\/\1>/);
  7. return result && result[2] ? result[2].trim() : '';
  8. }
  9. export function stripTemplate(content) {
  10. content = content.trim();
  11. if (!content) {
  12. return content;
  13. }
  14. return content.replace(/<(script|style)[\s\S]+<\/\1>/g, '').trim();
  15. }