Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/fleetbase.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/fleetbase.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/sdk",
"version": "1.2.12",
"version": "1.2.13",
"description": "Fleetbase JS & Node SDK",
"repository": "https://github.com/fleetbase/fleetbase-js",
"license": "AGPL-3.0-or-later",
Expand Down
39 changes: 31 additions & 8 deletions src/utils/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,15 @@ export default class String {
tableize(str) {
str = str || this.str;

// Temporarily disable chaining so that singularize and camelize return strings.
const originalChain = this.chain;
this.chain = false;

str = this.pluralize(this.underscore(str));

// Restore the original chaining setting.
this.chain = originalChain;

// set str
this.str = str;

Expand All @@ -352,19 +359,35 @@ export default class String {
String.classify('message_bus_properties') -> 'MessageBusProperty'
*/
classify(str) {
// Use the provided string or fallback to the instance's string.
str = str || this.str;
// Ensure we're working with a string and remove any extra whitespace.
str = `${str}`.trim();

str = this.singularize(this.camelize(str));
// Normalize the input:
// Replace one or more spaces, dashes, or underscores with a single underscore.
// This handles cases like "service-area", "service area", "service_area", etc.
str = str.replace(/[\s\-_]+/g, '_');

// set str
this.str = str;
// Temporarily disable chaining so that singularize and camelize return strings.
const originalChain = this.chain;
this.chain = false;

if (this.chain === true) {
return this;
}
// First, singularize the underscored string.
str = this.singularize(str);

// return result
return str;
// Next, camelize the result.
// Passing false for the lowFirstLetter parameter ensures the first letter is capitalized.
str = this.camelize(str, false);

// Restore the original chaining setting.
this.chain = originalChain;

// Update the instance's string.
this.str = str;

// Return the instance if chaining is enabled, or the string otherwise.
return this.chain ? this : str;
}

/*
Expand Down
Loading