Skip to content

Commit eebf1fb

Browse files
committed
fix(http-multipart): issue where IE 11 was stripping needed '/' from paths
1 parent 217466f commit eebf1fb

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
1.08
2+
========
3+
Fixed issue in IE11 that was stripping leading '/' on urls which in turned caused the routing in web api to fail.
4+
15
1.07
26
========
37
Fixed deploy issue
8+
49
1.06
510
========
611
Fixed deploy issue
12+
713
1.0.5
814
========
915
Added ability to have fine grained control over the request that get batched by adding an optional canBatchRequest function on the configuration object.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-http-batcher",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Angular (2+) HTTP batching module to reduce the number of HTTP requests and increase performance",
55
"scripts": {
66
"build": "./node_modules/.bin/ngc -p ./src",

src/adapters/http-multipart-mixed-boundary-adapter.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,20 @@ export class HttpMultipartMixedBoundaryAdapter implements IBatchHttpRequestAdapt
143143
private getUrlParts(url: string): { host: string; path: string, search: string } {
144144
const anchorElement = document.createElement("a");
145145
anchorElement.href = url;
146+
// IE < 11 & Safari 11 seem to remove the proceeding '/' form urls
147+
// which causings routing errors in web api
148+
// https://localhost:44379/authentication/profile/current should be
149+
// path: "/authentication/profile/current"
150+
// in IE it is
151+
// path: "authentication/profile/current"
146152
return {
147153
host: anchorElement.host,
148-
path: anchorElement.pathname,
154+
path: this.ensureLeadingBackSlash(anchorElement.pathname),
149155
search: anchorElement.search
150156
};
151157
}
158+
159+
private ensureLeadingBackSlash(path: string): string {
160+
return path[0] === "/" ? path : `/${path}`;
161+
}
152162
}

0 commit comments

Comments
 (0)