Compare commits

...

4 Commits
3.4.0 ... 3.5.1

Author SHA1 Message Date
semantic-release-bot
016823880d chore(release): 3.5.1 [skip ci]
## [3.5.1](http://github.com/rlespinasse/github-slug-action/compare/3.5.0...3.5.1) (2021-03-31)

### Bug Fixes

* update dist files ([e6c550f](e6c550f88c))
2021-03-31 06:58:56 +00:00
Mark Allen
e6c550f88c fix: update dist files 2021-03-31 08:57:45 +02:00
semantic-release-bot
4060fda269 chore(release): 3.5.0 [skip ci]
# [3.5.0](http://github.com/rlespinasse/github-slug-action/compare/3.4.0...3.5.0) (2021-03-30)

### Features

* allow underscore in slug values ([475d293](475d293680))
2021-03-30 20:05:12 +00:00
Mark Allen
475d293680 feat: allow underscore in slug values 2021-03-30 22:04:00 +02:00
6 changed files with 40 additions and 26 deletions

View File

@@ -1,3 +1,17 @@
## [3.5.1](http://github.com/rlespinasse/github-slug-action/compare/3.5.0...3.5.1) (2021-03-31)
### Bug Fixes
* update dist files ([e6c550f](http://github.com/rlespinasse/github-slug-action/commit/e6c550f88ccca52a82675b89186b6b72864f087c))
# [3.5.0](http://github.com/rlespinasse/github-slug-action/compare/3.4.0...3.5.0) (2021-03-30)
### Features
* allow underscore in slug values ([475d293](http://github.com/rlespinasse/github-slug-action/commit/475d293680b998a3315846828329f05bfff4ac9c))
# [3.4.0](http://github.com/rlespinasse/github-slug-action/compare/3.3.0...3.4.0) (2021-03-02)

View File

@@ -29,7 +29,7 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
`SLUG` on a variable will
- put the variable content in lower case
- replace any character by `-` except `0-9`, `a-z`, and `.`
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
- remove leading and trailing `-` character
- limit the string size to 63 characters

View File

@@ -16,13 +16,13 @@ test('slug_ref:: master branch', () => {
})
test('slug_ref: a feature branch', () => {
test_slugref('refs/heads/feat/new_feature', 'feat-new-feature')
test_slugref_cs('refs/heads/feat/new_feature', 'feat-new-feature')
test_slugref('refs/heads/feat/new_feature', 'feat-new_feature')
test_slugref_cs('refs/heads/feat/new_feature', 'feat-new_feature')
})
test('slug_ref: a fix branch', () => {
test_slugref('refs/heads/fix/issue_number', 'fix-issue-number')
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
test_slugref('refs/heads/fix/issue_number', 'fix-issue_number')
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue_number')
})
test('slug_ref: a simple tag', () => {
@@ -36,8 +36,8 @@ test('slug_ref: a complex tag', () => {
})
test('slug_ref: a reference with upper case letters', () => {
test_slugref('refs/heads/New_Awesome_Product', 'new-awesome-product')
test_slugref_cs('refs/heads/New_Awesome_Product', 'New-Awesome-Product')
test_slugref('refs/heads/New_Awesome_Product', 'new_awesome_product')
test_slugref_cs('refs/heads/New_Awesome_Product', 'New_Awesome_Product')
})
test('slug_ref: test trailing', () => {

18
dist/index.js vendored
View File

@@ -742,7 +742,7 @@ exports.slugurlref = exports.slugurlref_cs = exports.slugurl = exports.slugurl_c
const MAX_SLUG_STRING_SIZE = 63;
/**
* slug_cs will take envVar and then :
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -754,7 +754,7 @@ exports.slug_cs = slug_cs;
/**
* slug will take envVar and then :
* - put the variable content in lower case
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -766,7 +766,7 @@ exports.slug = slug;
/**
* slugref_cs will take envVar and then :
* - remove refs/(heads|tags|pull)/
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -779,7 +779,7 @@ exports.slugref_cs = slugref_cs;
* slugref will take envVar and then :
* - remove refs/(heads|tags|pull)/
* - put the variable content in lower case
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -796,7 +796,7 @@ exports.slugref = slugref;
* @param envVar to be slugged
*/
function slugurl_cs(envVar) {
return slug_cs(replaceAnyDotToHyphen(envVar));
return slug_cs(replaceAnyNonUrlCharactersWithHyphen(envVar));
}
exports.slugurl_cs = slugurl_cs;
/**
@@ -808,7 +808,7 @@ exports.slugurl_cs = slugurl_cs;
* @param envVar to be slugged
*/
function slugurl(envVar) {
return slug(replaceAnyDotToHyphen(envVar));
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar));
}
exports.slugurl = slugurl;
/**
@@ -840,10 +840,10 @@ function trailHyphen(envVar) {
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '');
}
function replaceAnyNonAlphanumericCharacter(envVar) {
return envVar.replace(RegExp('[^a-zA-Z0-9.]', 'g'), '-');
return envVar.replace(RegExp('[^a-zA-Z0-9._]', 'g'), '-');
}
function replaceAnyDotToHyphen(envVar) {
return envVar.replace(RegExp('[.]', 'g'), '-');
function replaceAnyNonUrlCharactersWithHyphen(envVar) {
return envVar.replace(RegExp('[._]', 'g'), '-');
}
function removeRef(envVar) {
return envVar.replace(RegExp('^refs/(heads|tags|pull)/'), '');

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@ const MAX_SLUG_STRING_SIZE = 63
/**
* slug_cs will take envVar and then :
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -17,7 +17,7 @@ export function slug_cs(envVar: string): string {
/**
* slug will take envVar and then :
* - put the variable content in lower case
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -29,7 +29,7 @@ export function slug(envVar: string): string {
/**
* slugref_cs will take envVar and then :
* - remove refs/(heads|tags|pull)/
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -42,7 +42,7 @@ export function slugref_cs(envVar: string): string {
* slugref will take envVar and then :
* - remove refs/(heads|tags|pull)/
* - put the variable content in lower case
* - replace any character by `-` except `0-9`, `a-z`, and `.`
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
* - remove leading and trailing `-` character
* - limit the string size to 63 characters
* @param envVar to be slugged
@@ -59,7 +59,7 @@ export function slugref(envVar: string): string {
* @param envVar to be slugged
*/
export function slugurl_cs(envVar: string): string {
return slug_cs(replaceAnyDotToHyphen(envVar))
return slug_cs(replaceAnyNonUrlCharactersWithHyphen(envVar))
}
/**
@@ -71,7 +71,7 @@ export function slugurl_cs(envVar: string): string {
* @param envVar to be slugged
*/
export function slugurl(envVar: string): string {
return slug(replaceAnyDotToHyphen(envVar))
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar))
}
/**
@@ -104,11 +104,11 @@ function trailHyphen(envVar: string): string {
}
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
return envVar.replace(RegExp('[^a-zA-Z0-9.]', 'g'), '-')
return envVar.replace(RegExp('[^a-zA-Z0-9._]', 'g'), '-')
}
function replaceAnyDotToHyphen(envVar: string): string {
return envVar.replace(RegExp('[.]', 'g'), '-')
function replaceAnyNonUrlCharactersWithHyphen(envVar: string): string {
return envVar.replace(RegExp('[._]', 'g'), '-')
}
function removeRef(envVar: string): string {