Skip to content

Commit 93f0480

Browse files
authored
Merge pull request #461 from mulesoft/develop
Develop
2 parents 21196a5 + 96ff07e commit 93f0480

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

dist/scripts/api-console.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
return {
154154
restrict: 'E',
155155
templateUrl: 'directives/documentation.tpl.html',
156-
controller: ['$scope', function($scope) {
156+
controller: ['$scope', 'idGenerator', function($scope, idGenerator) {
157157
$scope.markedOptions = RAML.Settings.marked;
158158

159159
$scope.$watch('securitySchemes', function() {
@@ -393,7 +393,7 @@
393393
};
394394

395395
$scope.getBodyId = function (bodyType) {
396-
return jQuery.trim(bodyType.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
396+
return idGenerator(bodyType.toString());
397397
};
398398

399399
$scope.bodySelected = function (value) {
@@ -1660,6 +1660,18 @@
16601660
.directive('resourcePanel', RAML.Directives.resourcePanel);
16611661
})();
16621662

1663+
(function () {
1664+
'use strict';
1665+
1666+
angular.module('RAML.Directives')
1667+
.factory('idGenerator', [function idGenerator() {
1668+
return function(value) {
1669+
var id = jQuery.trim(value.replace(/\W/g, ' ')).replace(/\s+/g, '_');
1670+
return id === '' ? '-' : id;
1671+
};
1672+
}]);
1673+
})();
1674+
16631675
(function () {
16641676
'use strict';
16651677

@@ -1699,9 +1711,9 @@
16991711
'use strict';
17001712

17011713
angular.module('RAML.Directives')
1702-
.factory('resourceId', [function resourceId() {
1714+
.factory('resourceId', ['idGenerator', function resourceId(idGenerator) {
17031715
return function(resource) {
1704-
return jQuery.trim(resource.pathSegments.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
1716+
return idGenerator(resource.pathSegments.toString());
17051717
};
17061718
}]);
17071719
})();
@@ -2132,7 +2144,7 @@
21322144
restrict: 'E',
21332145
templateUrl: 'directives/root-documentation.tpl.html',
21342146
replace: true,
2135-
controller: ['$scope', '$timeout', function($scope, $timeout) {
2147+
controller: ['$scope', '$timeout', 'idGenerator', function($scope, $timeout, idGenerator) {
21362148
$scope.markedOptions = RAML.Settings.marked;
21372149
$scope.selectedSection = 'all';
21382150

@@ -2145,7 +2157,7 @@
21452157
};
21462158

21472159
$scope.generateDocId = function (path) {
2148-
return jQuery.trim(path.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_').toLowerCase();
2160+
return idGenerator(path.toString());
21492161
};
21502162

21512163
$scope.toggleSection = function ($event, key, section) {

src/app/directives/documentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
return {
66
restrict: 'E',
77
templateUrl: 'directives/documentation.tpl.html',
8-
controller: ['$scope', function($scope) {
8+
controller: ['$scope', 'idGenerator', function($scope, idGenerator) {
99
$scope.markedOptions = RAML.Settings.marked;
1010

1111
$scope.$watch('securitySchemes', function() {
@@ -245,7 +245,7 @@
245245
};
246246

247247
$scope.getBodyId = function (bodyType) {
248-
return jQuery.trim(bodyType.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
248+
return idGenerator(bodyType.toString());
249249
};
250250

251251
$scope.bodySelected = function (value) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('RAML.Directives')
5+
.factory('idGenerator', [function idGenerator() {
6+
return function(value) {
7+
var id = jQuery.trim(value.replace(/\W/g, ' ')).replace(/\s+/g, '_');
8+
return id === '' ? '-' : id;
9+
};
10+
}]);
11+
})();

src/app/directives/resource-tree/resource-id.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
'use strict';
33

44
angular.module('RAML.Directives')
5-
.factory('resourceId', [function resourceId() {
5+
.factory('resourceId', ['idGenerator', function resourceId(idGenerator) {
66
return function(resource) {
7-
return jQuery.trim(resource.pathSegments.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
7+
return idGenerator(resource.pathSegments.toString());
88
};
99
}]);
1010
})();

src/app/directives/root-documentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
restrict: 'E',
77
templateUrl: 'directives/root-documentation.tpl.html',
88
replace: true,
9-
controller: ['$scope', '$timeout', function($scope, $timeout) {
9+
controller: ['$scope', '$timeout', 'idGenerator', function($scope, $timeout, idGenerator) {
1010
$scope.markedOptions = RAML.Settings.marked;
1111
$scope.selectedSection = 'all';
1212

@@ -19,7 +19,7 @@
1919
};
2020

2121
$scope.generateDocId = function (path) {
22-
return jQuery.trim(path.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_').toLowerCase();
22+
return idGenerator(path.toString());
2323
};
2424

2525
$scope.toggleSection = function ($event, key, section) {

0 commit comments

Comments
 (0)