Wizards: Fix regular expressions

Although this is valid JavaScript matching the '.' is
not working as expected.
The directory always gets messed up by replacing the
first character with a dash. Use an alternate regular
expression and also ensure the replacement happens
globally instead of once as we want to replace all
dots by a dash.
As at it fix handling of the file suffixes as well.

Task-number: QTCREATORBUG-22625
Change-Id: Ide189fe50e29994abfb368e503050b9b413aba9f
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2019-06-25 09:27:31 +02:00
parent 33d49ec072
commit 6288e03264
5 changed files with 7 additions and 7 deletions

View File

@@ -9,7 +9,7 @@
"iconText": "java", "iconText": "java",
"enabled": "%{JS: value('Plugins').indexOf('Android') >= 0}", "enabled": "%{JS: value('Plugins').indexOf('Android') >= 0}",
"options": [ { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/\\.java$/,'')}" } ], "options": [ { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/[.]java$/,'')}" } ],
"pages" : "pages" :
[ [

View File

@@ -14,7 +14,7 @@
{ "key": "vcsId", "value": "B.Bazaar" }, { "key": "vcsId", "value": "B.Bazaar" },
{ "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" },
{ "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }" }, { "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }" },
{ "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"},
{ "key": "RevArg", "value": "%{JS: '%{Rev}' !== '' ? '-r' : ''}" }, { "key": "RevArg", "value": "%{JS: '%{Rev}' !== '' ? '-r' : ''}" },
{ "key": "TargetPath", "value": "%{Path}/%{Dir}" } { "key": "TargetPath", "value": "%{Path}/%{Dir}" }
], ],

View File

@@ -13,8 +13,8 @@
[ [
{ "key": "vcsId", "value": "G.Git" }, { "key": "vcsId", "value": "G.Git" },
{ "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" },
{ "key": "SR", "value": "%{JS: '%{Repo}'.replace(/\\.git$/, '') }"}, { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/[.]git$/, '') }"},
{ "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"},
{ "key": "branchArg", "value": "%{JS: '%{Branch}' ? '--branch' : '' }" }, { "key": "branchArg", "value": "%{JS: '%{Branch}' ? '--branch' : '' }" },
{ "key": "TargetPath", "value": "%{Path}/%{Dir}" } { "key": "TargetPath", "value": "%{Path}/%{Dir}" }
], ],

View File

@@ -14,7 +14,7 @@
{ "key": "vcsId", "value": "H.Mercurial" }, { "key": "vcsId", "value": "H.Mercurial" },
{ "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" },
{ "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }"}, { "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }"},
{ "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"},
{ "key": "TargetPath", "value": "%{Path}/%{Dir}" } { "key": "TargetPath", "value": "%{Path}/%{Dir}" }
], ],

View File

@@ -13,8 +13,8 @@
[ [
{ "key": "vcsId", "value": "J.Subversion" }, { "key": "vcsId", "value": "J.Subversion" },
{ "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" },
{ "key": "SR", "value": "%{JS: '%{Repo}'.replace(/\\/trunk$/, '').replace(/\\/$/, '') }"}, { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/[/]trunk$/, '').replace(/[/]$/, '') }"},
{ "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"},
{ "key": "TargetPath", "value": "%{Path}/%{Dir}" } { "key": "TargetPath", "value": "%{Path}/%{Dir}" }
], ],