
Product
Announcing Bun and vlt Support in Socket
Bringing supply chain security to the next generation of JavaScript package managers
com.devskiller.friendly-id:friendly-id-project
Advanced tools
Library to convert uuid to url friendly IDs basing on base62
UUID Friendly ID
c3587ec5-0976-497f-8374-61e0c2ea3da5 -> 7NLCAyd6sKR7kDHxgAWFPG
| |
36 characters 22 characters
Just add friendly-id starter dependency:
<dependency>
<groupId>com.devskiller.friendly-id</groupId>
<artifactId>friendly-id-spring-boot-starter</artifactId>
<version>1.0.4</version>
</dependency>
Sample application:
@SpringBootApplication
@RestController
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@GetMapping("/bars/{bar}")
public Bar getBar(@PathVariable UUID bar) {
return new Bar(UUID.randomUUID());
}
@Value
class Bar {
private final UUID id;
}
}
Result:
curl 'localhost:8080/bars/5fD1KwsxRcGhBqWNju0jzt'
{"id":"52OMXhWiAqUWwII0c97Svl"}
Application uses internally UUID, but from external point of view only friendly id is visible.
This allows to write much simpler tests for our code, because you can use names instead of hard to remember UUIDs.
mockMvc.perform(get("/bars/{bar}", "sampleBar"))
.andExpect(status().isOk())
.andExpect(jsonPath("$._links.self.href", is("http://localhost/bars/sampleBar")));
There is no need to define UUID value for bar, sampleBar is decoded to valid UUID identifier.
Dependency:
<dependency>
<groupId>com.devskiller.friendly-id</groupId>
<artifactId>friendly-id</artifactId>
<version>1.0.4</version>
</dependency>
FriendlyId.createFriendlyId();
// 7NLCAyd6sKR7kDHxgAWFPG
FriendlyId.toUuid("7NLCAyd6sKR7kDHxgAWFPG");
// c3587ec5-0976-497f-8374-61e0c2ea3da5
FriendlyId.toFriendlyId(UUID.fromString("c3587ec5-0976-497f-8374-61e0c2ea3da5"));
// 7NLCAyd6sKR7kDHxgAWFPG
Id 00cafe is equal to cafe - leading zeros are ignored.
UUID is a 128-bit number, so id also can store only 128-bit number
Add jackson module dependency:
<dependency>
<groupId>com.devskiller.friendly-id</groupId>
<artifactId>friendly-id-jackson-datatype</artifactId>
<version>1.0.4</version>
</dependency>
Register friendly_id module:
ObjectMapper mapper = new ObjectMapper()
.registerModule(new FriendlyIdModule());
FAQs
Library to convert uuid to url friendly IDs basing on base62
We found that com.devskiller.friendly-id:friendly-id-project demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

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.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.