Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit b3ae345

Browse files
authored
fix(http): Fix compatibility with Angular versions < 2.3
1 parent 3cd4e5a commit b3ae345

File tree

5 files changed

+5603
-6
lines changed

5 files changed

+5603
-6
lines changed

demo/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<a class="navbar-brand" href="#">Stormpath Angular SDK</a>
2424
</div>
2525
<ul class="nav navbar-nav hidden-xs">
26-
<li><a href="#demo">Demo</a></li>
2726
<li><a href="https://github.com/stormpath/stormpath-sdk-angular#installation">Installation</a></li>
2827
<li><a href="https://docs.stormpath.com/angular/api">Documentation</a></li>
2928
</ul>

src/stormpath/stormpath.http.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ export class StormpathHttp extends Http {
8484
options.headers = new Headers();
8585
}
8686

87+
let version: string = (VERSION) ? VERSION.full : '2.x';
8788
if (this.config.endpointUris.indexOf(requestUri) > -1) {
88-
options.headers.set('X-Stormpath-Agent', 'stormpath-sdk-angular/' + this.config.version + ' angular/' + VERSION.full);
89+
options.headers.set('X-Stormpath-Agent', 'stormpath-sdk-angular/' + this.config.version + ' angular/' + version);
8990
if (url instanceof Request) {
90-
url.headers.set('X-Stormpath-Agent', 'stormpath-sdk-angular/' + this.config.version + ' angular/' + VERSION.full);
91+
url.headers.set('X-Stormpath-Agent', 'stormpath-sdk-angular/' + this.config.version + ' angular/' + version);
9192
}
9293
}
9394

webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPl
77
const TOKENS = {
88
VERSION: JSON.stringify(require('./package.json').version).replace(/['"]+/g, '')
99
};
10-
1110
module.exports = {
1211
devtool: IS_PROD ? 'source-map' : 'eval',
1312
entry: './demo/entry.ts',

webpack.config.umd.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ module.exports = {
3636
loaders: ['awesome-typescript-loader', 'angular2-template-loader?keepUrl=true'],
3737
exclude: [/\.(spec|e2e)\.ts$/, /node_modules/]
3838
},
39+
/* Replace version from package.json */
40+
{
41+
test: /\.config.ts$/,
42+
loader: StringReplacePlugin.replace({
43+
replacements: [{
44+
pattern: /\${(.*)}/g,
45+
replacement: function (match, p1, offset, string) {
46+
return TOKENS[p1];
47+
}
48+
}]
49+
})
50+
},
3951
/* Embed files. */
4052
{
4153
test: /\.(html|css)$/,
@@ -58,13 +70,16 @@ module.exports = {
5870
VERSION: JSON.stringify(require('./package.json').version)
5971
}),
6072
new webpack.HotModuleReplacementPlugin(),
61-
new LoaderOptionsPlugin({
73+
// the LoaderOptionsPlugin is necessary to configure tslint, but causes issues with StringReplacePlugin
74+
// https://github.com/wbuchwalter/tslint-loader/issues/38
75+
/*new LoaderOptionsPlugin({
6276
options: {
6377
tslint: {
6478
emitErrors: false,
6579
failOnHint: false
6680
}
6781
}
68-
})
82+
}),*/
83+
new StringReplacePlugin()
6984
]
7085
};

0 commit comments

Comments
 (0)