Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ditojs/utils

Package Overview
Dependencies
Maintainers
2
Versions
424
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ditojs/utils - npm Package Compare versions

Comparing version
2.69.0
to
2.70.0
+21
src/html/stripHtml.js
import { deprecate } from '../function/deprecate.js'
export function stripHtml(html) {
return html != null
? html
.toString()
.replace(/<br\/?>/gi, '\n')
.replace(/<[^>]+>/g, '')
: ''
}
/**
* @deprecated Use stripHtml() instead
*/
export function stripTags(html) {
deprecate(
'The `stripTags` function is deprecated in favour of `stripHtml`. ' +
'Update your code to use `stripHtml` instead.'
)
return stripHtml(html)
}
import { stripHtml } from './stripHtml.js'
describe('stripHtml()', () => {
it('should remove html tags from strings', () => {
expect(stripHtml('<p><b>this</b> is a marked-up string</p>'))
.toBe('this is a marked-up string')
})
it('should return an empty string if nothing can be processed', () => {
expect(stripHtml()).toBe('')
expect(stripHtml(null)).toBe('')
expect(stripHtml('')).toBe('')
})
it('should handle falsy values correctly', () => {
expect(stripHtml(0)).toBe('0')
expect(stripHtml(false)).toBe('false')
})
it('should convert <br> tags to line-breaks', () => {
expect(stripHtml('hello<br>world')).toBe('hello\nworld')
expect(stripHtml('hello<br/>world')).toBe('hello\nworld')
})
})
+2
-2
{
"name": "@ditojs/utils",
"version": "2.69.0",
"version": "2.70.0",
"type": "module",

@@ -42,3 +42,3 @@ "description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",

},
"gitHead": "a2b28ad175cd3280ceadd394c74ba67e12da03af"
"gitHead": "2010c0695b5a7296e10c2b6bf2539d552c576fd9"
}
export * from './escapeHtml.js'
export * from './stripTags.js'
export * from './stripHtml.js'

@@ -705,2 +705,10 @@ // Type definitions for Dito.js utils

*/
export function stripHtml(html: string): string
/**
* Strips HTML tags from the string.
* @param html The string to strip.
* @returns The newly stripped string.
* @deprecated Use stripHtml() instead
*/
export function stripTags(html: string): string

@@ -707,0 +715,0 @@

// TODO: Rename to stripHtml()
export function stripTags(html) {
return html != null
? html
.toString()
.replace(/<br\/?>/gi, '\n')
.replace(/<[^>]+>/g, '')
: ''
}
import { stripTags } from './stripTags.js'
describe('stripTags()', () => {
it('should remove html tags from strings', () => {
expect(stripTags('<p><b>this</b> is a marked-up string</p>'))
.toBe('this is a marked-up string')
})
it('should return an empty string if nothing can be processed', () => {
expect(stripTags()).toBe('')
expect(stripTags(null)).toBe('')
expect(stripTags('')).toBe('')
})
it('should handle falsy values correctly', () => {
expect(stripTags(0)).toBe('0')
expect(stripTags(false)).toBe('false')
})
it('should convert <br> tags to line-breaks', () => {
expect(stripTags('hello<br>world')).toBe('hello\nworld')
expect(stripTags('hello<br/>world')).toBe('hello\nworld')
})
})

Sorry, the diff of this file is not supported yet