Skip to content

Commit b7dfc4f

Browse files
committed
Forgot to compile the scripts. Shit happens.
1 parent 4f1476c commit b7dfc4f

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

dist/angular-environment.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
angular.module('environment', []).
1313
provider('envService', function() {
1414

15+
'use strict';
16+
17+
var local = {};
18+
19+
local.pregQuote = function(string, delimiter) {
20+
return (string + '').replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&');
21+
};
22+
23+
local.stringToRegex = function(string) {
24+
return new RegExp(local.pregQuote(string).replace(/\\\*/g, '.*').replace(/\\\?/g, '.'), 'g');
25+
};
26+
1527
this.environment = 'development'; // default
1628
this.data = {}; // user defined environments data
1729

@@ -55,11 +67,14 @@ angular.module('environment', []).
5567
* @return {Void}
5668
*/
5769
this.read = function(variable) {
58-
if (variable !== 'all') {
59-
return this.data.vars[this.get()][variable];
70+
if (typeof variable === 'undefined' || variable === '' || variable === 'all') {
71+
return this.data.vars[this.get()];
72+
}
73+
else if (typeof this.data.vars[this.get()][variable] === 'undefined') {
74+
return this.data.vars.defaults[variable];
6075
}
6176

62-
return this.data.vars[this.get()];
77+
return this.data.vars[this.get()][variable];
6378
};
6479

6580
/**
@@ -82,13 +97,15 @@ angular.module('environment', []).
8297
* @return {Void}
8398
*/
8499
this.check = function() {
85-
var location = window.location.href,
100+
var location = window.location.host,
86101
self = this;
87102

88103
angular.forEach(this.data.domains, function(v, k) {
89104
angular.forEach(v, function(v) {
90-
if (location.match('//' + v)) {
105+
if (location.match(local.stringToRegex(v))) {
91106
self.environment = k;
107+
108+
return false;
92109
}
93110
});
94111
});

dist/angular-environment.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)