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

Fixes #8: Strip all not supported chars in manufacturer slug #42

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

FloEisen
Copy link
Contributor

@FloEisen FloEisen commented Nov 24, 2021

There is a problem with stripping special characters from manufacturers names for the slug.
For example: "Rohde & Schwarz" would be stripped down to "rohde_&_schwarz" which is not a clean solution.
When manually creating a manufacturer in Netbox with that name, Netbox strips the slug down to "rohde-schwarz" which is much cleaner.

So I implemented a change which strips all special characters (and white spaces) and replaces them with a single hyphen (-). This solves the problem of special chars other than white spaces, and also when there are multiple behind each other.
Also changed the underscore to hyphen as the Netbox uses hyphens by default (avoiding problems with existing manufacturer entries).

A few examples:
Rohde & Schwarz --> rohde-schwarz
Palo Alto --> palo-alto
Example - Vendor --> example-vendor

Technical explanation: Used the regular expression module with \W+ (equivalent to [^a-zA-Z0-9_]) as this matches any non-word chars.

Fixes #8

@minitriga minitriga merged commit d11a527 into netbox-community:master Nov 24, 2021
@FloEisen FloEisen deleted the Fix--Issue-#8 branch November 24, 2021 09:46
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

Successfully merging this pull request may close these issues.

Strip invalid spaces from Manufacturer slug generation
2 participants