Skip to content

Bug: route_to() does not return relative part of the path #2971

Description

@SoulReaver

Describe the bug
route_to() helper function according to docs:

Generates a relative URI ...

While the generated path is not relative but "rooted" (I am not sure how it's called properly). If used in views, e.g. to build links/anchors, those will be relative to domain, not to base_url.

CodeIgniter 4 version
4.0.3 - current release

Affected module(s)
Routes or user-guide/docs

Expected behavior, and steps to reproduce if appropriate
Let's consider this example:
example page in service: example.com/ci-blog/login
base url: example.com/ci-blog/
url to the page relative to base url: login
route_to returns: /login
which points to: example.com/login

Expected behavior - route_to to return parts of path relative to base_url, i.e. without slash at the beginning.

Current workaround for CI user is to add dot at the beginning of every link generated by route_to or remove slash manually.

Context

  • OS: Windows 10
  • Web server: Apache 2.4.41
  • PHP version: 7.3.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions