Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Apr 21, 2017
1 parent dc383cf commit e775c54
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/lib/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function init (options, directory, locals) {

res.locals.polyfillCallbackName = polyfillIo.callbackName;
res.locals.polyfillUrls = {
enhanced: polyfillRoot + polyfillIo.getQueryString({enhanced: true}),
core: polyfillRoot + polyfillIo.getQueryString({enhanced: false})
enhanced: polyfillRoot + polyfillIo.getQueryString('enhanced'),
core: polyfillRoot + polyfillIo.getQueryString('core')
}

res.locals.javascriptBundles.push(
Expand Down
18 changes: 7 additions & 11 deletions server/lib/polyfill-io.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const sharedQueryConfig = {
enhanced: {
features: [
Expand All @@ -10,8 +9,7 @@ const sharedQueryConfig = {
'fetch',
'Array.prototype.find',
'Array.prototype.findIndex',
// alwyas pending https://github.com/Financial-Times/polyfill-service/pull/1041
'Array.prototype.includes|always|gated',
'Array.prototype.includes',
'IntersectionObserver',
'Map',
'Array.from',
Expand All @@ -29,12 +27,6 @@ const sharedQueryConfig = {

const callbackName = 'ftNextPolyfillServiceCallback';

const queryStrings = ['enhanced', 'core']
.reduce((configsMap, configName) => {
configsMap[configName] = buildQueryString(configName)
return configsMap;
}, {})

function buildQueryString (configName) {
const qs = [];

Expand All @@ -54,9 +46,13 @@ function buildQueryString (configName) {
return `?${qs.join('&')}`;
}

const queryStrings = Object.keys(sharedQueryConfig)
.reduce((configsMap, configName) => {
configsMap[configName] = buildQueryString(configName)
return configsMap;
}, {})

module.exports = {
callbackName,
getQueryString: opts => queryStrings[optsToString(opts)],
getAllQueryStrings: () => queryStrings
getQueryString: setting => queryStrings[setting]
}
2 changes: 1 addition & 1 deletion server/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('simple app', function () {
it('should have preload link headers for css and js resources', done => {
request(app)
.get('/templated')
.expect('Link', /<https:\/\/next-geebee\.ft\.com\/.*polyfill.min\.js.*>; as="script"; rel="preload"; nopush/)
.expect('Link', /<https:\/\/www\.ft\.com\/.*polyfill.min\.js.*>; as="script"; rel="preload"; nopush/)
.expect('Link', /<\/\/www\.ft\.com\/__assets\/n-ui\/cached\/v1\.1\.1\/es5\.min\.js>; as="script"; rel="preload"; nopush/)
// .expect('Link', /<\/\/www\.ft\.com\/__assets\/n-ui\/cached\/v1\.1\.1\/n-ui-core\.css>; as="style"; rel="preload"; nopush/)
.expect('Link', /<\/demo-app\/main\.css>; as="style"; rel="preload"; nopush/)
Expand Down

0 comments on commit e775c54

Please sign in to comment.