Skip to content

Commit

Permalink
Merge pull request #537 from edx/mroytman/fixup-create-worker
Browse files Browse the repository at this point in the history
prepend LMS Root URL to relative Javascript URLs if LMS Root URL is d…
  • Loading branch information
MichaelRoytman authored Feb 13, 2019
2 parents 23c9443 + e123bd3 commit 8e8566c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion edx_proctoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
from __future__ import absolute_import

# Be sure to update the version number in edx_proctoring/package.json
__version__ = '1.5.11'
__version__ = '1.5.12'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
10 changes: 9 additions & 1 deletion edx_proctoring/backends/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from webpack_loader.utils import get_files
from webpack_loader.exceptions import BaseWebpackLoaderException, WebpackBundleLookupError

from django.conf import settings

from edx_proctoring.backends.backend import ProctoringBackendProvider
from edx_proctoring.exceptions import (
BackendProviderCannotRegisterAttempt,
Expand Down Expand Up @@ -122,6 +124,13 @@ def get_javascript(self):
u'Webpack stats file corresponding to WebWorkers not found: {}'
.format(str(err))
)

# if the Javascript URL is not an absolute URL (i.e. doesn't have a scheme), prepend
# the LMS Root URL to it, if it is defined, to make it an absolute URL
if not js_url.startswith('http'):
if hasattr(settings, 'LMS_ROOT_URL'):
js_url = settings.LMS_ROOT_URL + js_url

return js_url

def get_software_download_url(self):
Expand Down Expand Up @@ -297,7 +306,6 @@ def _get_language_headers(self):
# This import is here because developers writing backends which subclass this class
# may want to import this module and use the other methods, without having to run in the context
# of django settings, etc.
from django.conf import settings
from django.utils.translation import get_language

current_lang = get_language()
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/static/proctoring/js/exam_action_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var edx = edx || {};
};

function createWorker(url) {
var blob = new Blob(["importScripts('" + location.origin + url + "');"], { "type": 'application/javascript' });
var blob = new Blob(["importScripts('" + url + "');"], { "type": 'application/javascript' });
var blobUrl = window.URL.createObjectURL(blob);
return new Worker(blobUrl);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@edx/edx-proctoring",
"//": "Be sure to update the version number in edx_proctoring/__init__.py",
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.",
"version": "1.5.11",
"version": "1.5.12",
"main": "edx_proctoring/static/index.js",
"repository": {
"type": "git",
Expand Down

0 comments on commit 8e8566c

Please sign in to comment.