Skip to content

Conversation

@bajrangCoder
Copy link
Member

@bajrangCoder bajrangCoder commented Jan 16, 2026

Links like <a href="about"> now resolve to about.html or about/index.html

Fixes: #1739

 Links like <a href="about"> now resolve to about.html or about/index.html

Fixes: Acode-Foundation#1739
@github-actions github-actions bot added the enhancement New feature or request label Jan 16, 2026
@gemini-code-assist

This comment was marked as resolved.

@bajrangCoder bajrangCoder added this to the 1.11.8 milestone Jan 16, 2026
gemini-code-assist[bot]

This comment was marked as resolved.

@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile Summary

Added extensionless URL resolution to the preview server. When a request comes in without a file extension (e.g., /about), the server now attempts to resolve it in this order: first to about.html, then to about/index.html. If neither exists, a 404 error is returned.

  • Properly checks for unsaved files in the editor before checking the filesystem
  • Maintains consistency with existing file-serving patterns
  • Correctly returns early after serving files to prevent fallthrough
  • Only applies when pathName is available (not in single-file mode)

The implementation is straightforward and solves the requested feature.

Confidence Score: 4/5

  • This PR is safe to merge with minor consideration for edge cases
  • The implementation correctly addresses the issue of extensionless URLs. The code follows existing patterns, properly checks for unsaved editor files before filesystem files, and handles fallback paths appropriately. The only minor concern is that it assumes all extensionless requests should resolve to HTML, which could prevent serving legitimate extensionless files like LICENSE or README (though this is an uncommon scenario in web preview contexts).
  • No files require special attention - the change is isolated and follows existing code patterns

Important Files Changed

Filename Overview
src/lib/run.js Added extensionless URL resolution that tries .html extension first, then /index.html fallback - implementation is solid with one minor limitation

Sequence Diagram

sequenceDiagram
    participant Browser
    participant Server as Preview Server
    participant EM as EditorManager
    participant FS as FileSystem
    
    Browser->>Server: GET /about (no extension)
    Server->>Server: Extract reqPath = "about"
    Server->>Server: Detect !ext && pathName
    
    Note over Server: Try path.html first
    Server->>EM: getFile("pathName/about.html")
    alt File loaded and unsaved in editor
        EM-->>Server: Return editor file
        Server->>Server: sendHTML(file.session.getValue())
        Server-->>Browser: 200 OK (HTML from editor)
    else Not in editor
        Server->>FS: fsOperation("pathName/about.html").exists()
        alt about.html exists
            FS-->>Server: true
            Server->>Server: sendFileContent(htmlUrl, MIMETYPE_HTML)
            Server-->>Browser: 200 OK (about.html)
        else about.html not found
            FS-->>Server: false
            Note over Server: Try path/index.html fallback
            Server->>FS: fsOperation("pathName/about/index.html").exists()
            alt about/index.html exists
                FS-->>Server: true
                Server->>Server: sendFileContent(indexUrl, MIMETYPE_HTML)
                Server-->>Browser: 200 OK (about/index.html)
            else index.html not found
                FS-->>Server: false
                Server->>Server: error(reqId)
                Server-->>Browser: 404 Not Found
            end
        end
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@bajrangCoder bajrangCoder merged commit bdbf86b into Acode-Foundation:main Jan 16, 2026
6 checks passed
@bajrangCoder bajrangCoder deleted the feat/extensionless-url-resolution branch January 16, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host html without extension (.html)

1 participant