New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

homoglyph

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homoglyph - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

13

index.js

@@ -15,7 +15,5 @@ 'use strict'

const chance = Math.random() < (opts.probability / 100)
return replace(text, dict, chance)
return replace(text, dict, () => Math.random() < (opts.probability / 100))
}
function splice (str, index, count, add) {

@@ -28,7 +26,14 @@ return str.slice(0, index) + add + str.slice(index + count)

let pos = 0
for (let char of original) {
const replacement = dict.get(char)
if (replacement !== undefined) {
const fakeLetter = Array.isArray(replacement) ? replacement[Math.floor(Math.random() * replacement.length)] : replacement
if (condition) text = splice(text, pos, 1, fakeLetter)
if (typeof condition === 'function') {
if (condition()) text = splice(text, pos, 1, fakeLetter)
} else {
text = splice(text, pos, 1, fakeLetter)
}
}

@@ -35,0 +40,0 @@

{
"name": "homoglyph",
"version": "1.0.1",
"version": "1.0.2",
"description": "Replace ascii chars with their same looking utf8 chars.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc