Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.slugify:slugify

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.slugify:slugify

SEO-friendly URLs with Slugify

  • 3.0.7
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Slugify

GitHub license javadoc

Description

Small utility library for generating speaking URLs.

Usage Examples

Basic

final Slugify slg = Slugify.builder().build();
final String result = slg.slugify("Hello, world!");
// result: hello-world

Underscore Separator

final Slugify slg = Slugify.builder().underscoreSeparator(true).build();
final String result = slg.slugify("Hello, world!");
// result: hello_world

Case Sensitive

final Slugify slg = Slugify.builder().lowerCase(false).build();
final String result = slg.slugify("Hello, world!");
// result: Hello-world

Specifying a Locale

final Slugify slg = Slugify.builder().locale(Locale.GERMAN).build();
final String result = slg.slugify("ä");
// result: ae

Custom Replacements

final Slugify slg = Slugify.builder()
    // provided as a map
    .customReplacements(Map.of("Foo", "Hello", "bar", "world"))
    // provided as single key-value
    .customReplacement("Foo", "Hello")
    .customReplacement("bar", "world")
    .build();

final String result = slg.slugify("Foo, bar!");
// result: hello-world

Transliteration

Requirements
Gradle 6+

For Gradle 6+ users there's a feature variant which can be used as follows:

capabilities {
    requireCapability('com.github.slugify:slugify-transliterator')
}

For more information about feature variants please check the section Modeling feature variants and optional dependencies of gradle's user guide.

Other

Manually add the optional dependency com.ibm.icu:icu4j to your project.

Usage Example
final Slugify slg = Slugify.builder().transliterator(true).build();
final String result = slg.slugify("Б");
// result: b

FAQs

Package last updated on 12 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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