Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 7, 2021
2 parents c53e8fc + 04cec8b commit d8f985c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/the_Foundation
Submodule the_Foundation updated from dd4bc4 to 5c16ed
15 changes: 10 additions & 5 deletions src/gmrequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,16 +597,18 @@ void submit_GmRequest(iGmRequest *d) {
else if (equalCase_Rangecc(url.scheme, "file")) {
/* TODO: Move handling of "file://" URLs elsewhere, it's getting complex. */
iString *path = collect_String(localFilePathFromUrl_String(&d->url));
/* Note: As a local file path, `path` uses the OS directory separators
(i.e., \ on Windows). `Archive` accepts both. */
iFile *f = new_File(path);
if (isDirectory_(path)) {
if (endsWith_String(path, "/")) {
if (endsWith_String(path, iPathSeparator)) {
removeEnd_String(path, 1);
}
resp->statusCode = success_GmStatusCode;
setCStr_String(&resp->meta, "text/gemini");
iString *page = collectNew_String();
iString *parentDir = collectNewRange_String(dirName_Path(path));
appendFormat_String(page, "=> %s " upArrow_Icon " %s/\n\n",
appendFormat_String(page, "=> %s " upArrow_Icon " %s" iPathSeparator "\n\n",
cstrCollect_String(makeFileUrl_String(parentDir)),
cstr_String(parentDir));
appendFormat_String(page, "# %s\n", cstr_Rangecc(baseName_Path(path)));
Expand All @@ -630,7 +632,7 @@ void submit_GmRequest(iGmRequest *d) {
appendFormat_String(page, "=> %s %s%s\n",
cstrCollect_String(makeFileUrl_String(path_FileInfo(entry))),
cstr_Rangecc(baseName_Path(path_FileInfo(entry))),
isDirectory_FileInfo(entry) ? "/" : "");
isDirectory_FileInfo(entry) ? iPathSeparator : "");
iRelease(entry);
}
set_Block(&resp->body, utf8_String(page));
Expand All @@ -652,7 +654,8 @@ void submit_GmRequest(iGmRequest *d) {
iString *entryPath = collect_String(copy_String(path));
remove_Block(&entryPath->chars, 0, size_String(container) + 1); /* last slash, too */
iBool isDir = isDirectory_Archive(arch, entryPath);
if (isDir && !isEmpty_String(entryPath) && !endsWith_String(entryPath, "/")) {
if (isDir && !isEmpty_String(entryPath) &&
!endsWith_String(entryPath, iPathSeparator)) {
/* Must have a slash for directories, otherwise relative navigation
will not work. */
resp->statusCode = redirectPermanent_GmStatusCode;
Expand Down Expand Up @@ -683,7 +686,9 @@ void submit_GmRequest(iGmRequest *d) {
const iRangecc parentDir = dirName_Path(collectNewRange_String(curDir));
if (!equal_Rangecc(parentDir, ".")) {
/* A subdirectory. */
appendFormat_String(page, "=> ../ " upArrow_Icon " %s/\n",
appendFormat_String(page,
"=> ../ " upArrow_Icon " %s" iPathSeparator
"\n",
cstr_Rangecc(parentDir));
}
else {
Expand Down
1 change: 1 addition & 0 deletions src/gmutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ iString *localFilePathFromUrl_String(const iString *d) {
if (startsWith_String(path, "/")) {
remove_Block(&path->chars, 0, 1);
}
replace_Block(&path->chars, '/', '\\');
#endif
return path;
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ void init_Window(iWindow *d, iRect rect) {
d->place.initialPos = rect.pos;
d->place.normalRect = rect;
d->place.lastNotifiedSize = zero_I2();
d->place.snap = 0;
d->pendingCursor = NULL;
d->isDrawFrozen = iTrue;
d->isExposed = iFalse;
Expand Down

0 comments on commit d8f985c

Please sign in to comment.