Skip to content

Commit 753440e

Browse files
committed
Merge pull request #123 from shakacode/josias-meta-tags-manager
meta tags manager using ES6 Array.from and upgrade to Node 4.2
2 parents ac8c4a8 + 3445116 commit 753440e

File tree

6 files changed

+4448
-2460
lines changed

6 files changed

+4448
-2460
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rvm:
44
- 2.2.2
55
install:
66
- bundle install
7+
- npm install -g npm
78
- npm install
89
- cd client && npm run build:client
910
- npm run build:server

client/app/utils/metaTagsManager.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ const MetaTagsManager = {
66
* @returns {String} - CSRF Token.
77
*/
88
getCSRFToken() {
9-
const metas = document.getElementsByTagName('meta');
10-
for (let i = 0; i < metas.length; i++) {
11-
const meta = metas[i];
12-
if (meta.getAttribute('name') === 'csrf-token') {
13-
return meta.getAttribute('content');
14-
}
15-
}
9+
const token = Array.from(document.getElementsByTagName('meta'))
10+
.find(tag => tag.name === 'csrf-token');
1611

17-
return null;
12+
return token ? token.content : null;
1813
},
1914
};
2015

0 commit comments

Comments
 (0)