Skip to content

Commit

Permalink
Workaround for the lack of baseURI under IE
Browse files Browse the repository at this point in the history
IE doesn't have the document.baseURI property.
This workaround constructs the baseURI if not present.
  • Loading branch information
gergely-ujvari committed May 9, 2014
1 parent 3f286f2 commit b3a18e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion h/js/app.coffee
Expand Up @@ -57,8 +57,14 @@ configure = [
redirectTo: '/viewer'

# Configure CSP for templates
# XXX: IE workaround for the lack of document.baseURI property
baseURI = document.baseURI
if not baseURI
baseTags = document.getElementsByTagName "base"
baseURI = if baseTags.length then baseTags[0].href else document.URL

# Explicitly whitelist '.html' paths adjacent to application base URI
basePattern = document.baseURI.replace /\/[^\/]*$/, '/*.html'
basePattern = baseURI.replace /\/[^\/]*$/, '/*.html'
$sceDelegateProvider.resourceUrlWhitelist ['self', basePattern]
]

Expand Down
7 changes: 6 additions & 1 deletion h/js/helpers.coffee
Expand Up @@ -2,7 +2,12 @@ baseURI = [
'$document'
($document) ->
# Strip an empty hash and end in exactly one slash
$document[0].baseURI.replace(/#$/, '').replace(/\/+$/, '/')
baseURI = $document[0].baseURI
# XXX: IE workaround for the lack of document.baseURI property
if not baseURI
baseTags = $document[0].getElementsByTagName "base"
baseURI = if baseTags.length then baseTags[0].href else $document[0].URL
baseURI.replace(/#$/, '').replace(/\/+$/, '/')
]


Expand Down

0 comments on commit b3a18e1

Please sign in to comment.