Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Simplify generation logic

Klaus Zanders81bc35da8e09
diff --git a/modules/github_integration/frontend/module/git-actions/git-actions.service.ts b/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
index 980b5958bd5..7744deddde1 100644
--- a/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
+++ b/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
@@ -37,11 +37,9 @@ export class GitActionsService {
// This sanitization tries to be harsher than those rules
return str
.replace(/&/g, "and ") // & becomes and
- .replace(/ +/g, "-") // Spaces become dashes
- .replace(/[^\w\-]+/g, "") // Remove any non ascii characters as they might make trouble in some tools
- .replace(/^[-]+/g, "") // Dashes at the start are removed
- .replace(/[-]+$/g, "") // Dashes at the end are removed
- .replace(/-+/g, "-") // Multiple dashes in a row are deduped
+ .replace(/\W+/g, "-") // Replace any consecutive non ascii characters by a single dash as they might make trouble in some tools.
+ .replace(/^-/g, "") // Dash at the start is removed
+ .replace(/-$/g, "") // Dash at the end is removed
.trim();
}
diff --git a/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts b/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts
index 63e612ebc2b..7332dd6b7c8 100644
--- a/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts
+++ b/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts
@@ -40,11 +40,9 @@ export class GitActionsService {
// This sanitization tries to be harsher than those rules
return str
.replace(/&/g, "and ") // & becomes and
- .replace(/ +/g, "-") // Spaces become dashes
- .replace(/[^\w\-]+/g, "") // Remove any non ascii characters as they might make trouble in some tools
- .replace(/^[-]+/g, "") // Dashes at the start are removed
- .replace(/[-]+$/g, "") // Dashes at the end are removed
- .replace(/-+/g, "-") // Multiple dashes in a row are deduped
+ .replace(/\W+/g, "-") // Replace any consecutive non ascii characters by a single dash as they might make trouble in some tools.
+ .replace(/^-/g, "") // Dash at the start is removed
+ .replace(/-$/g, "") // Dash at the end is removed
.trim();
}