Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

names that are "too similar" should not display as available #11

Open
chase-moskal opened this issue Feb 1, 2022 · 3 comments
Open

Comments

@chase-moskal
Copy link

npm has a mechanism to prevent publishing with names similar to existing packages.

for example, snapstate is shown as available in this app,

however, the name is too similar to snap-state, and thus cannot be published.

@remarkablemark
Copy link
Owner

You're right @chase-moskal. However, there's no easy way to determine that via the public API. This may be something that may be too complex to handle for this simple website.

@chase-moskal
Copy link
Author

@remarkablemark, ah, that's too bad npm doesn't provide a proper api for this case.

perhaps there's a workaround -- maybe this site could query http://registry.npmjs.com/-/v1/search?text=<searchstring>&size=20 to pull up a list that includes the similar names, and then remove all hypens from the names, to check if there is a name that matches

const packageName = "snapstate"
const similarNames = await querySimilarPackageNames(packageName)
const similarNamesWithoutHyphens = similarNames.map(name => name.replace("-", ""))
const packageNameWithoutHyphens = packageName.replace("-", "")

const isTooSimilar = similarNamesWithoutHyphens.includes(packageNameWithoutHyphens)

just a thought

@remarkablemark
Copy link
Owner

Thanks for sharing your approach. I'll see if I have time to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants