forked from unpkg/unpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
312 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module.exports = { | ||
moduleNameMapper: { | ||
"\\.css$": "<rootDir>/modules/__mocks__/styleMock.js" | ||
'entry-manifest': '<rootDir>/modules/__mocks__/entryManifest.js', | ||
'\\.png$': '<rootDir>/modules/__mocks__/imageMock.js', | ||
'\\.css$': '<rootDir>/modules/__mocks__/styleMock.js' | ||
}, | ||
setupTestFrameworkScriptFile: | ||
"<rootDir>/modules/__tests__/setupTestFramework.js", | ||
testMatch: ["**/__tests__/*-test.js"], | ||
testURL: "http://localhost/" | ||
testMatch: ['**/__tests__/*-test.js'], | ||
testURL: 'http://localhost/' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["@babel/preset-env", { "loose": true, "targets": "node 8" }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import request from 'supertest'; | ||
|
||
import createServer from '../createServer'; | ||
|
||
describe('Invalid package names', () => { | ||
let server; | ||
beforeEach(() => { | ||
server = createServer(); | ||
}); | ||
|
||
it('are rejected', done => { | ||
request(server) | ||
.get('/_invalid/index.js') | ||
.end((err, res) => { | ||
expect(res.statusCode).toBe(403); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import request from 'supertest'; | ||
|
||
import createServer from '../createServer'; | ||
|
||
describe('Invalid query params', () => { | ||
let server; | ||
beforeEach(() => { | ||
server = createServer(); | ||
}); | ||
|
||
it('redirect to the same path w/out those params', done => { | ||
request(server) | ||
.get('/d3?module&invalid-param') | ||
.end((err, res) => { | ||
expect(res.statusCode).toBe(302); | ||
expect(res.headers.location).toBe('/d3?module'); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import request from 'supertest'; | ||
|
||
import createServer from '../createServer'; | ||
|
||
describe('Legacy URLs', () => { | ||
let server; | ||
beforeEach(() => { | ||
server = createServer(); | ||
}); | ||
|
||
it('redirect /_meta to ?meta', done => { | ||
request(server) | ||
.get('/_meta/react') | ||
.end((err, res) => { | ||
expect(res.statusCode).toBe(301); | ||
expect(res.headers.location).toBe('/react?meta'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('redirect ?json to ?meta', done => { | ||
request(server) | ||
.get('/react?json') | ||
.end((err, res) => { | ||
expect(res.statusCode).toBe(301); | ||
expect(res.headers.location).toBe('/react?meta'); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import e from './createElement'; | ||
import h from './createHTML'; | ||
import x from './createScript'; | ||
import e from './createElement.js'; | ||
import h from './createHTML.js'; | ||
import x from './createScript.js'; | ||
|
||
const promiseShim = | ||
'window.Promise || document.write(\'\\x3Cscript src="/[email protected]/dist/es6-promise.min.js">\\x3C/script>\\x3Cscript>ES6Promise.polyfill()\\x3C/script>\')'; | ||
|
@@ -11,12 +11,12 @@ const fetchShim = | |
'window.fetch || document.write(\'\\x3Cscript src="/[email protected]/dist/fetch.umd.js">\\x3C/script>\')'; | ||
|
||
export default function MainTemplate({ | ||
title, | ||
description, | ||
favicon, | ||
title = 'UNPKG', | ||
description = 'The CDN for everything on npm', | ||
favicon = '/favicon.ico', | ||
data, | ||
content, | ||
elements | ||
content = h(''), | ||
elements = [] | ||
}) { | ||
return e( | ||
'html', | ||
|
@@ -47,14 +47,6 @@ export default function MainTemplate({ | |
); | ||
} | ||
|
||
MainTemplate.defaultProps = { | ||
title: 'UNPKG', | ||
description: 'The CDN for everything on npm', | ||
favicon: '/favicon.ico', | ||
content: h(''), | ||
elements: [] | ||
}; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
const htmlType = PropTypes.shape({ | ||
__html: PropTypes.string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import invariant from 'invariant'; | ||
|
||
import createElement from './createElement'; | ||
import createElement from './createElement.js'; | ||
|
||
export default function getGlobalScripts(entryPoint, globalURLs) { | ||
return entryPoint.globalImports.map(id => { | ||
invariant(globalURLs[id], 'Missing global URL for id "%s"', id); | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (!globalURLs[id]) { | ||
throw new Error('Missing global URL for id "%s"', id); | ||
} | ||
} | ||
|
||
return createElement('script', { src: globalURLs[id] }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.