This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
fix(module-map): missing baseUrl to module map on server #206
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76c6388
fix(module-map): missing baseUrl to module map on server
infoxicator 6a53429
Merge branch 'master' into fix/module-map-base-url
Francois-Esquire a2d8d75
fix(baseUrl): use existing baseURl from module map
infoxicator 3f73102
Merge branch 'fix/module-map-base-url' of https://github.com/american…
infoxicator bfab43b
Merge branch 'master' into fix/module-map-base-url
Francois-Esquire 25d1a0f
Merge branch 'master' into fix/module-map-base-url
nellyk 0e758c6
fix(baseUrl): remove default baseUrl value from map
infoxicator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2019 American Express Travel Related Services Company, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import addBaseUrlToModuleMap from '../../../src/server/utils/addBaseUrlToModuleMap'; | ||
|
||
const moduleMap = { | ||
modules: { | ||
'module-a': { | ||
node: { | ||
url: 'https://example.com/cdn/module-a/1.0.0/module-a.node.js', | ||
integrity: '234', | ||
}, | ||
browser: { | ||
url: 'https://example.com/cdn/module-a/1.0.0/module-a.browser.js', | ||
integrity: '353', | ||
}, | ||
legacyBrowser: { | ||
url: 'https://example.com/cdn/module-a/1.0.0/module-a.legacy.browser.js', | ||
integrity: '0087', | ||
}, | ||
}, | ||
'module-b': { | ||
node: { | ||
url: 'https://example.com/cdn/module-b/1.0.0/module-b.node.js', | ||
integrity: '0322380', | ||
}, | ||
browser: { | ||
url: 'https://example.com/cdn/module-b/1.0.0/module-b.browser.js', | ||
integrity: 'sd3o23098', | ||
}, | ||
legacyBrowser: { | ||
url: 'https://example.com/cdn/module-b/1.0.0/module-b.legacy.browser.js', | ||
integrity: 'flj23032', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('addBaseUrlToModuleMap', () => { | ||
it('creates a "baseUrl" entry for each module and returns a module map including the new key', () => { | ||
const updatedModuleMap = addBaseUrlToModuleMap(moduleMap); | ||
Object.keys(updatedModuleMap.modules).forEach((moduleName) => { | ||
const module = updatedModuleMap.modules[moduleName]; | ||
expect(module.baseUrl).toBe(`https://example.com/cdn/${moduleName}/1.0.0/`); | ||
}); | ||
}); | ||
|
||
it('does not override the baseUrl key if already present in the module map', () => { | ||
const moduleMapWithBaseUrl = { | ||
...moduleMap, | ||
modules: { | ||
...moduleMap.modules, | ||
'module-a': { | ||
...moduleMap.modules['module-a'], | ||
baseUrl: 'https://example.com/languages/module-a/1.0.0/', | ||
}, | ||
}, | ||
}; | ||
const updatedModuleMap = addBaseUrlToModuleMap(moduleMapWithBaseUrl); | ||
const moduleA = updatedModuleMap.modules['module-a']; | ||
const moduleB = updatedModuleMap.modules['module-b']; | ||
expect(moduleA.baseUrl).toBe('https://example.com/languages/module-a/1.0.0/'); | ||
expect(moduleB.baseUrl).toBe('https://example.com/cdn/module-b/1.0.0/'); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2020 American Express Travel Related Services Company, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
/* The baseUrl key in the module map is used by one-app-ducks to construct | ||
the language pack URL pointing at the location of the language pack */ | ||
const addBaseUrlToModuleMap = (moduleMap) => ({ | ||
...moduleMap, | ||
modules: Object.entries(moduleMap.modules).reduce((acc, [moduleName, moduleBundles]) => ( | ||
{ | ||
...acc, | ||
[moduleName]: { | ||
...moduleBundles, | ||
baseUrl: moduleBundles.baseUrl ? moduleBundles.baseUrl : moduleBundles.node.url.replace(/[^/]+\.js$/i, ''), | ||
}, | ||
} | ||
), {}), | ||
}); | ||
|
||
export default addBaseUrlToModuleMap; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this option should be documented