diff options
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/lib/utils/text_utility.js | 20 | ||||
-rw-r--r-- | app/assets/javascripts/releases/components/release_block_header.vue | 4 |
2 files changed, 19 insertions, 5 deletions
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js index 9ed286826cc..f857e618d89 100644 --- a/app/assets/javascripts/lib/utils/text_utility.js +++ b/app/assets/javascripts/lib/utils/text_utility.js @@ -142,11 +142,25 @@ export const stripHtml = (string, replace = '') => { }; /** - * Converts snake_case string to camelCase + * Converts a snake_cased string to camelCase. + * Leading and trailing underscores are ignored. * - * @param {*} string + * @param {String} string The snake_cased string to convert + * @returns {String} A camelCased version of the string + * + * @example + * + * // returns "aSnakeCasedString" + * convertToCamelCase('a_snake_cased_string') + * + * // returns "_leadingUnderscore" + * convertToCamelCase('_leading_underscore') + * + * // returns "trailingUnderscore_" + * convertToCamelCase('trailing_underscore_') */ -export const convertToCamelCase = string => string.replace(/(_\w)/g, s => s[1].toUpperCase()); +export const convertToCamelCase = string => + string.replace(/([a-z0-9])_([a-z0-9])/gi, (match, p1, p2) => `${p1}${p2.toUpperCase()}`); /** * Converts camelCase string to snake_case diff --git a/app/assets/javascripts/releases/components/release_block_header.vue b/app/assets/javascripts/releases/components/release_block_header.vue index f0d3f3f8c1d..0bc2a5ce2eb 100644 --- a/app/assets/javascripts/releases/components/release_block_header.vue +++ b/app/assets/javascripts/releases/components/release_block_header.vue @@ -20,10 +20,10 @@ export default { }, computed: { editLink() { - return this.release.Links?.editUrl; + return this.release._links?.editUrl; }, selfLink() { - return this.release.Links?.self; + return this.release._links?.self; }, }, }; |