Last active
April 28, 2025 15:12
-
-
Save c0m1c5an5/a4b41e808243cfd45592698180c8f938 to your computer and use it in GitHub Desktop.
GitLab CI Slugify Implementation Pure Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation of https://gitlab.com/gitlab-org/gitlab/-/blob/master/gems/gitlab-utils/lib/gitlab/utils.rb#L56 | |
slugify() { | |
local reply | |
unset REPLY ERR | |
reply="${*,,}" | |
reply="${reply//[^a-z0-9]/-}" | |
reply="${reply:0:63}" | |
while [[ ${reply} == -* ]]; do reply="${reply#-}"; done | |
while [[ ${reply} == *- ]]; do reply="${reply%-}"; done | |
REPLY="${reply}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment