dashboardjavacloudcoapiotiot-analyticsiot-platformiot-solutionskafkalwm2mmicroservicesmiddlewaremqttnettyplatformsnmpthingsboardvisualizationwebsocketswidgets
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
564 B
23 lines
564 B
'use strict'
|
|
|
|
var decode = require('parse-entities')
|
|
|
|
module.exports = length
|
|
|
|
var ampersand = '&'
|
|
|
|
// Returns the length of HTML entity that is a prefix of the given string
|
|
// (excluding the ampersand), 0 if it does not start with an entity.
|
|
function length(value) {
|
|
var prefix
|
|
|
|
/* istanbul ignore if - Currently also tested for at implemention, but we
|
|
* keep it here because that’s proper. */
|
|
if (value.charAt(0) !== ampersand) {
|
|
return 0
|
|
}
|
|
|
|
prefix = value.split(ampersand, 2).join(ampersand)
|
|
|
|
return prefix.length - decode(prefix).length
|
|
}
|
|
|