Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(store): new function for converting page names to ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Palmaswell authored and lkuechler committed Feb 15, 2018
1 parent 2d7d75e commit cad182b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ export class Store {
return guessedName.substring(0, 1).toUpperCase() + guessedName.substring(1);
}

/**
* Tries to guess a technical (internal) ID from the name by removing,
* empty spaces, periods and dashes.
* @param name The human-friendly name.
* @return The guessed technical (internal) ID.
*/
public static convertToId(name: string): string {
const guessedId = name
.replace(/([' '])/, '-')
.replace(/([_])/, '-')
.replace(/([.])/, '')
.toLowerCase();
return guessedId;
}

/**
* Add a new project definition to the list of projects.
* Note: Changes to the projects and page references are saved only when calling save().
Expand Down

0 comments on commit cad182b

Please sign in to comment.