bitbucketslugbitbucket-server

Atlassian slug generatorGenerator


Does Atlassian slug generation algorithm or any of its implementation public?

I need to check if repository name typed by user will have certain slug.

I found a lot of different algorithms, but I need to be sure that that's one used by Stash, where it's written that slug generation is done by BitBucket.


Solution

  • I didn't find it anywhere, but I suppose it looks like this:

    Name cannot have other chars than letters, digits, whitespaces, hyphens, underscores and periods! Also its first char needs to be a letter or digit.

    As a whitespace block I mean text found by regex: [\s]+.

    1. Every whitespace block replace with simple hyphen.

      My \t Exaple Text. -> My-Example-Text.

    2. Lowercase all letters in string.

      My-Example-Text. -> my-example-text.