Skip to content

Commit

Permalink
fix(h5p-server): fixed url generation for absolulte library files (#1180
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sr258 authored Mar 14, 2021
1 parent 04baa97 commit 665c18e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/h5p-server/src/UrlGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export default class UrlGenerator implements IUrlGenerator {
`${this.baseUrl()}${this.config.editorLibraryUrl}/`;

public libraryFile = (library: IFullLibraryName, file: string): string => {
if (file.startsWith('http://') || file.startsWith('https://')) {
if (
file.startsWith('http://') ||
file.startsWith('https://') ||
file.startsWith('/')
) {
return file;
}
return `${this.baseUrl()}${this.config.librariesUrl}/${
Expand Down
2 changes: 2 additions & 0 deletions packages/h5p-server/test/H5PPlayer.renderHtmlPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ describe('Rendering the HTML page', () => {
scripts: [
...scripts,
'preload3.js',
'/preload4.js',
'https://example.com/script.js'
],
styles: [styles[0], styles[1]]
Expand Down Expand Up @@ -540,6 +541,7 @@ describe('Rendering the HTML page', () => {
'/h5p/libraries/Foo-1.0/preload3.js?version=1.0.0'
)
).toBe(true);
expect((model as any).scripts.includes('/preload4.js')).toBe(true);
expect(
(model as any).scripts.includes('https://example.com/script.js')
).toBe(true);
Expand Down

0 comments on commit 665c18e

Please sign in to comment.