diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py
index e13ac81fe0..822346453a 100644
--- a/src/calibre/ebooks/epub/from_html.py
+++ b/src/calibre/ebooks/epub/from_html.py
@@ -108,7 +108,7 @@ def find_html_index(files):
html_files = [f[0] for f in html_files]
for q in ('toc', 'index'):
for f in html_files:
- if os.path.splitext(f)[0].lower() == q:
+ if os.path.splitext(os.path.basename(f))[0].lower() == q:
return f, os.path.splitext(f)[1].lower()[1:]
return html_files[-1], os.path.splitext(html_files[-1])[1].lower()[1:]
diff --git a/src/calibre/trac/plugins/download.py b/src/calibre/trac/plugins/download.py
index 1c2b95c668..014a26bff3 100644
--- a/src/calibre/trac/plugins/download.py
+++ b/src/calibre/trac/plugins/download.py
@@ -379,5 +379,4 @@ else:
pi = os.path.join(destdir, 'calibre_postinstall')
subprocess.call(pi, shell=True)
return 0
- ''')
-
+ ''')
\ No newline at end of file