Skip to content

Commit

Permalink
fix: throw an error on incorrect usage
Browse files Browse the repository at this point in the history
added some minor cases where the code should throw an error.
  • Loading branch information
zypA13510 committed Apr 17, 2020
1 parent 565b841 commit 3208a46
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/ui5-fontawesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ sap.ui.require([
'use strict'

function getResourceRoot() {
var scriptTag = document.querySelector('SCRIPT[src][id=ui5-fontawesome]')
var scriptTag = document.querySelector('script[id=ui5-fontawesome]')
if (!scriptTag) {
throw new Error('Failed to locate ui5-fontawesome script tag.')
}
var scriptConfig = scriptTag.getAttribute('data-resourceroot')
if (scriptConfig) {
return scriptConfig.slice(-1) == '/' ? scriptConfig : scriptConfig + '/'
}
var scriptSrc = scriptTag.getAttribute('src')
if (!scriptSrc) {
throw new Error('Failed to determine resource root for ui5-fontawesome.')
}
var regexTest = /^((?:.*\/)?ui5-fontawesome\/)/
var matched = regexTest.exec(scriptSrc)
if (matched) {
Expand Down

0 comments on commit 3208a46

Please sign in to comment.