Skip to content

Commit

Permalink
using fullpath, fixes Malformed url bug #2
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Sep 17, 2024
1 parent f0ec992 commit 8c37cef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ All needed js and css files are packaged in a single `index.html` file for deplo
- Python version: >= 3.6
- Pyhton dependencies: see [requirements.txt](requirements.txt)
- Javascript dependencies (already included): JSLists
- Hosting server needs to allow [CORS calls](https://docs.turbowarp.org/url-parameters#project_url)
- **Hosting server needs to allow [CORS calls](https://docs.turbowarp.org/url-parameters#project_url)**


## Credits:
Expand Down
16 changes: 9 additions & 7 deletions publish_sb3.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,28 @@ def make_html_page(args):

with open(f'{args.root}/index.html', 'w', encoding='utf8') as write_f:



if not args.debug:
print('packing...')

soup = BeautifulSoup(res, "lxml")
links = list(soup.select("link"))
for tag in links:
print('Reading link', tag['href'])
with open(tag['href'], 'r', encoding='utf8') as link_f:
t = link_f.read()
#print(t)
fullpath = os.path.join(os.path.dirname(__file__), tag['href'])
with open(fullpath, 'r', encoding='utf8') as link_f:
t = link_f.read()
new_tag = soup.new_tag("style")
new_tag.string = t
tag.replace_with(new_tag)

scripts = list(soup.select('script["src"]'))
scripts = list(soup.find_all('script'))
for tag in scripts:
print('Reading script', tag['src'])
with open(tag['src'], 'r', encoding='utf8') as link_f:
t = link_f.read()
#print(t)
fullpath = os.path.join(os.path.dirname(__file__), tag['src'])
with open(fullpath, 'r', encoding='utf8') as link_f:
t = link_f.read()
new_tag = soup.new_tag("script")
new_tag.string = t
tag.replace_with(new_tag)
Expand Down

0 comments on commit 8c37cef

Please sign in to comment.