Skip to content

Commit

Permalink
improve url detection
Browse files Browse the repository at this point in the history
  • Loading branch information
laffra committed Dec 11, 2023
1 parent 8b8ad8b commit de9d001
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ltk/jquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def inject_script(file_or_url_or_text, type=None, worker=None):
try:
script = create("<script>").text(open(file_or_url_or_text).read())
except:
if file_or_url_or_text.startswith("http"):
if file_or_url_or_text.endswith(".js"):
script = create("<script>").attr("src", file_or_url_or_text)
else:
script = create("<script>").text(file_or_url_or_text)
Expand All @@ -150,10 +150,10 @@ def inject_css(file_or_url_or_text):
try:
node = create("<style>").text(open(file_or_url_or_text).read())
except:
if file_or_url_or_text.startswith("http"):
node = create("<link>").attr("rel", "stylesheet").attr("href", file_or_url_or_text)
else:
if "{" in file_or_url_or_text:
node = create("<style>").text(file_or_url_or_text)
else:
node = create("<link>").attr("rel", "stylesheet").attr("href", file_or_url_or_text)
node.appendTo(window.document.head)


Expand Down

0 comments on commit de9d001

Please sign in to comment.