Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 759 Bytes

isSSRSafeAttrName.md

File metadata and controls

26 lines (17 loc) · 759 Bytes
标题 标签
isSSRSafeAttrName(是否是安全合法的属性名) regexp,key(正则表达式,属性名)

是否是安全合法的属性名。

  • 使用正则表达式检查属性名是否安全且合法。
const isSSRSafeAttrName = key => !/[>/="'\u0009\u000a\u000c\u0020]/.test(key);

调用方式:

isSSRSafeAttrName('>'); // false
isSSRSafeAttrName('key'); // true

应用场景

结果如下:

<iframe src="codes/javascript/html/isSSRSafeAttrName.html"></iframe>