|
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | 13 | * See the License for the specific language governing permissions and
|
14 |
| - * limitations under the License. |
| 14 | + * limitations under the License. |
15 | 15 | */
|
16 | 16 |
|
17 | 17 | var imfService;
|
18 | 18 | var applicationId;
|
19 | 19 |
|
20 | 20 | var FilterUtil = {};
|
21 | 21 |
|
22 |
| -FilterUtil.getJson = function(jsonData) { |
| 22 | +FilterUtil.getJson = function (jsonData) { |
23 | 23 | var json = jsonData;
|
24 | 24 | if (typeof jsonData == 'string') {
|
25 |
| - json = JSON.parse(jsonData); |
| 25 | + json = JSON.parse (jsonData); |
26 | 26 | }
|
27 | 27 |
|
28 | 28 | return json;
|
29 | 29 | }
|
30 | 30 |
|
31 |
| -FilterUtil.clone = function(object) { |
| 31 | +FilterUtil.clone = function (object) { |
32 | 32 | var cloneObj = {};
|
33 | 33 |
|
34 |
| - if (object) { |
35 |
| - for(var prop in object) { |
| 34 | + if (object) { |
| 35 | + for (var prop in object) { |
36 | 36 | cloneObj[prop] = object[prop];
|
37 | 37 | }
|
38 | 38 | }
|
39 | 39 | return cloneObj;
|
40 | 40 | }
|
41 | 41 |
|
42 |
| -FilterUtil.getEnvProperty = function(propName,defaultValue) { |
| 42 | +FilterUtil.getEnvProperty = function (propName, defaultValue) { |
43 | 43 | var result = process.env[propName] || defaultValue;
|
44 | 44 | if (result) {
|
45 |
| - result = result.trim(); |
| 45 | + result = result.trim (); |
46 | 46 | }
|
47 | 47 |
|
48 | 48 | return result;
|
49 | 49 | }
|
50 | 50 |
|
51 |
| -FilterUtil.getAppIdFromUrl = function(url) { |
| 51 | +FilterUtil.getAppIdFromUrl = function (url) { |
52 | 52 | var result = null;
|
53 | 53 | var reg = /([0-9,a-f]{8}-[0-9,a-f]{4}-[0-9,a-f]{4}-[0-9,a-f]{4}-[0-9,a-f]{12}){1}/ig;
|
54 | 54 | if (url) {
|
55 |
| - var matches = url.match(reg); |
56 |
| - result = matches && matches.length>0 && matches[0]; |
| 55 | + var matches = url.match (reg); |
| 56 | + result = matches && matches.length > 0 && matches[0]; |
57 | 57 | }
|
58 | 58 |
|
59 | 59 | return result;
|
60 | 60 | }
|
61 | 61 |
|
62 |
| -FilterUtil.getApplicationIdFromVcap = function() { |
63 |
| - if (! applicationId) { |
64 |
| - var imfService = getImfService(); |
| 62 | +FilterUtil.getApplicationIdFromVcap = function () { |
| 63 | + if (!applicationId) { |
| 64 | + var imfService = getImfService (); |
65 | 65 | applicationId = imfService && imfService['credentials'] && imfService['credentials']['tenantId'];
|
66 | 66 | }
|
67 | 67 | return applicationId;
|
68 | 68 | }
|
69 | 69 |
|
70 |
| -FilterUtil.getServerUrlFromVcap = function() { |
71 |
| - var imfService = getImfService(); |
| 70 | +FilterUtil.getServerUrlFromVcap = function () { |
| 71 | + var imfService = getImfService (); |
72 | 72 | var serverUrl = imfService && imfService['credentials'] && imfService['credentials']['serverUrl'];
|
73 | 73 |
|
74 | 74 | return serverUrl;
|
75 | 75 | }
|
76 | 76 |
|
77 |
| -FilterUtil.getArrayFromString = function(value,delim) { |
| 77 | +FilterUtil.getArrayFromString = function (value, delim) { |
78 | 78 | var array = [];
|
79 | 79 | if (value) {
|
80 |
| - var a = value.split(delim); |
81 |
| - if (a && a.length>0) { |
82 |
| - a.forEach(function(item){ |
83 |
| - array.push(item.trim()); |
| 80 | + var a = value.split (delim); |
| 81 | + if (a && a.length > 0) { |
| 82 | + a.forEach (function (item) { |
| 83 | + array.push (item.trim ()); |
84 | 84 | });
|
85 | 85 | }
|
86 | 86 | }
|
87 | 87 | return array;
|
88 | 88 | }
|
89 | 89 |
|
90 |
| -FilterUtil.getMcaServiceCredentials = function (){ |
91 |
| - var mcaServiceInfo = getImfService(); |
| 90 | +FilterUtil.getMcaServiceCredentials = function () { |
| 91 | + var mcaServiceInfo = getImfService (); |
92 | 92 | var credentials = mcaServiceInfo && mcaServiceInfo["credentials"];
|
93 | 93 | return credentials;
|
94 | 94 | }
|
95 | 95 |
|
96 |
| -function getImfService() { |
| 96 | +function getImfService () { |
97 | 97 | if (!imfService) {
|
98 |
| - var vcapServices = FilterUtil.getJson(process.env['VCAP_SERVICES']); |
| 98 | + var vcapServices = FilterUtil.getJson (process.env['VCAP_SERVICES']); |
99 | 99 | for (var prop in vcapServices) {
|
100 |
| - if (prop.indexOf('AdvancedMobileAccess') == 0 && vcapServices[prop].length > 0) { |
| 100 | + if (prop.indexOf ('AdvancedMobileAccess') === 0 && vcapServices[prop].length > 0 || |
| 101 | + prop.indexOf ('AppID') === 0 && vcapServices[prop].length > 0) { |
101 | 102 | imfService = vcapServices[prop][0];
|
102 | 103 | }
|
103 | 104 | }
|
|
0 commit comments