Opening an /index.php/apps/deck/... URL on a pretty-URL instance rewrites it to /apps/deck/index.php/apps/deck/...

Đang mở Phù hợp với người mới
#8,782 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu từ src/router.js quanh đoạn tính URL gốc (dòng 16-23), rồi so sánh với bước dọn /index.php trong App.vue mounted(). Để tái hiện, mở /index.php/apps/deck/board/<id>/card/<id> trên một instance có modRewriteWorking === true và quan sát lần gọi routerHistory.replace đầu tiên. Xong khi một URL như vậy giữ nguyên như đã mở hoặc được chuẩn hóa thành /apps/deck/board/<id>/card/<id>, và việc điều hướng URL thân thiện thông thường vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

On an instance with pretty URLs enabled (front_controller_active, so OC.config.modRewriteWorking === true), opening a Deck URL that contains /index.php leaves the browser at a doubled path:

https://cloud.example.com/index.php/apps/deck/board/5/card/1589
  → address bar: https://cloud.example.com/apps/deck/index.php/apps/deck/board/5/card/1589

/index.php/... links are common: Nextcloud's server generates them whenever pretty URLs are off, and integrations use them because they work on every instance.

Cause

src/router.js:

const baseUrl = generateUrl('/apps/deck/')
const webRootWithIndexPHP = getRootUrl() + '/index.php'
const doesURLContainIndexPHP = window.location.pathname.startsWith(webRootWithIndexPHP)
const currentBaseUrl = doesURLContainIndexPHP ? baseUrl : baseUrl.replace('/index.php/', '/')

This assumes generateUrl('/apps/deck/') always returns /index.php/apps/deck/. When modRewriteWorking is true it returns /apps/deck/, so a URL that does contain /index.php gets the base /apps/deck/. Then:

  1. vue-router can't strip that base from /index.php/apps/deck/board/5/card/1589, so the route path is the whole pathname.
  2. On the first navigation the router calls routerHistory.replace(fullPath), i.e. replaceState(base + fullPath) = /apps/deck + /index.php/apps/deck/board/5/card/1589.

The cleanup in App.vue mounted() (redirect when $route.path starts with /index.php) doesn't rescue it in practice.

To Reproduce

  1. Use an instance with pretty URLs enabled (htaccess.RewriteBase set, Apache with mod_rewrite).
  2. Open https://<host>/index.php/apps/deck/board/<id>/card/<id> (or /index.php/apps/deck/board/<id>).
  3. The address bar shows https://<host>/apps/deck/index.php/apps/deck/board/<id>/....

Expected behavior

The URL stays as opened, or is normalised to /apps/deck/board/<id>/card/<id>.

Possible fix

Build the base from the current URL rather than from generateUrl():

const webRoot = getRootUrl()
const doesURLContainIndexPHP = window.location.pathname.startsWith(webRoot + '/index.php/')
const currentBaseUrl = webRoot + (doesURLContainIndexPHP ? '/index.php' : '') + '/apps/deck/'

Workaround

/index.php/apps/deck/card/<cardId> (page#redirectToCard) works, because the server redirects with linkToRouteAbsolute(), which drops index.php when pretty URLs are on. Board links have no equivalent redirect route.

Server details

Web server: Apache (official nextcloud Docker image, Helm chart, apache-pretty-urls.config.php enabled)

Nextcloud version: 35.0.3

Deck: current release from the app store. The code above is unchanged on main at 5be5601a.

Ngôn ngữ chính
JavaScript
Star
1.4k
Fork
369
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
86

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nextcloud/deck

Tất cả issue của nextcloud/deck

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.