summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-04 21:16:19 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-04 21:16:41 +0200
commit9a4032bbba8846d1f5c92b4c39743dc6884f06ec (patch)
treecf43e133677d6d1ea40e87d24e80c3ffbe0062e1
parentabec43cd54a14c6d4a74239df97870a83cc474ed (diff)
Windows: Dealing with "file:///" URIs
-rw-r--r--src/gmrequest.c9
-rw-r--r--src/gmutil.c5
2 files changed, 13 insertions, 1 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index a1284078..2402cc40 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -526,6 +526,12 @@ void submit_GmRequest(iGmRequest *d) {
526 } 526 }
527 else if (equalCase_Rangecc(url.scheme, "file")) { 527 else if (equalCase_Rangecc(url.scheme, "file")) {
528 iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); 528 iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path))));
529#if defined (iPlatformMsys)
530 /* Remove the extra slash from the beginning. */
531 if (startsWith_String(path, "/")) {
532 remove_Block(&path->chars, 0, 1);
533 }
534#endif
529 iFile * f = new_File(path); 535 iFile * f = new_File(path);
530 if (open_File(f, readOnly_FileMode)) { 536 if (open_File(f, readOnly_FileMode)) {
531 /* TODO: Check supported file types: images, audio */ 537 /* TODO: Check supported file types: images, audio */
@@ -555,6 +561,9 @@ void submit_GmRequest(iGmRequest *d) {
555 else if (endsWithCase_String(path, ".mp3")) { 561 else if (endsWithCase_String(path, ".mp3")) {
556 setCStr_String(&resp->meta, "audio/mpeg"); 562 setCStr_String(&resp->meta, "audio/mpeg");
557 } 563 }
564 else if (endsWithCase_String(path, ".mid")) {
565 setCStr_String(&resp->meta, "audio/midi");
566 }
558 else { 567 else {
559 setCStr_String(&resp->meta, "application/octet-stream"); 568 setCStr_String(&resp->meta, "application/octet-stream");
560 } 569 }
diff --git a/src/gmutil.c b/src/gmutil.c
index 557a82f8..94f00ce1 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -192,7 +192,10 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat
192iString *makeFileUrl_String(const iString *localFilePath) { 192iString *makeFileUrl_String(const iString *localFilePath) {
193 iString *url = cleaned_Path(localFilePath); 193 iString *url = cleaned_Path(localFilePath);
194 replace_Block(&url->chars, '\\', '/'); /* in case it's a Windows path */ 194 replace_Block(&url->chars, '\\', '/'); /* in case it's a Windows path */
195 set_String(url, collect_String(urlEncodeExclude_String(url, "/"))); 195 set_String(url, collect_String(urlEncodeExclude_String(url, "/:")));
196#if defined (iPlatformMsys)
197 prependChar_String(url, '/'); /* three slashes */
198#endif
196 prependCStr_String(url, "file://"); 199 prependCStr_String(url, "file://");
197 return url; 200 return url;
198} 201}