diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-12-05 14:22:48 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-12-05 14:22:48 +0300 |
commit | c5d5dfe83341dc49c0a38e051724421a6571972e (patch) | |
tree | 2934699fb2d28c91a64a1bf012c936148e16a1e1 /app | |
parent | 0f90fd639c9ed387426e0a8ec3a23ac33b37024c (diff) | |
parent | 4efdbdb266ae15e1effb768b5fea7ee3d0027e66 (diff) |
Merge branch 'fix-compatibility-with-ie11-for-merge-requests' into 'master'
Fix compatibility with Internet Explorer 11 for merge requests
## What does this MR do?
This merge request restores the compatibility with Internet Explorer 11.
## Are there points in the code the reviewer needs to double check?
No.
## Why was this MR needed?
Commit ca3c0c6cd915d44ec2d409b04ab05d964bd5a403 introduced an incompatibility with Internet Explorer 11. On all merge requests in all projects the 'Changes' tab does not display the changes in IE11 but instead fails with 'Something went wrong on our end'. The reason ist, that this code snipped produces different results on Firefox and Internet Explorer 11:
```
var element = document.createElement('a');
element.href = '/some/absolute/url';
alert(element.pathname);
```
With Internet Explorer 11 the alert will print a relative path, whereas with Firefox the alert will print an absolute path. For GitLab this meant that a wrong AJAX URL was composed which resulted in a 404.
## Screenshots (if relevant)
None.
## Does this MR meet the acceptance criteria?
- [X] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
- [X] Added for this feature/bug
- [ ] All builds are passing
- [X] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [X] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [X] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
## What are the relevant issue numbers?
#23977
#24380
See merge request !7525
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 13 | ||||
-rw-r--r-- | app/assets/javascripts/merge_request_tabs.js.es6 | 5 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 29cba1a49dd..8fa80502d92 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -97,6 +97,19 @@ return $('body').data('page').split(':')[0]; }; + gl.utils.parseUrl = function (url) { + var parser = document.createElement('a'); + parser.href = url; + return parser; + }; + + gl.utils.parseUrlPathname = function (url) { + var parsedUrl = gl.utils.parseUrl(url); + // parsedUrl.pathname will return an absolute path for Firefox and a relative path for IE11 + // We have to make sure we always have an absolute path. + return parsedUrl.pathname.charAt(0) === '/' ? parsedUrl.pathname : '/' + parsedUrl.pathname; + }; + gl.utils.isMetaKey = function(e) { return e.metaKey || e.ctrlKey || e.altKey || e.shiftKey; }; diff --git a/app/assets/javascripts/merge_request_tabs.js.es6 b/app/assets/javascripts/merge_request_tabs.js.es6 index 583fb9fc03d..3ec0f1fd613 100644 --- a/app/assets/javascripts/merge_request_tabs.js.es6 +++ b/app/assets/javascripts/merge_request_tabs.js.es6 @@ -225,11 +225,10 @@ // We extract pathname for the current Changes tab anchor href // some pages like MergeRequestsController#new has query parameters on that anchor - const url = document.createElement('a'); - url.href = source; + const urlPathname = gl.utils.parseUrlPathname(source); this.ajaxGet({ - url: `${url.pathname}.json${location.search}`, + url: `${urlPathname}.json${location.search}`, success: (data) => { $('#diffs').html(data.html); |