From 3439808d63abef4e8247989bb011a74ba474fa16 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 1 Aug 2021 12:40:01 +0800 Subject: [PATCH] fix: resolve path failed before PJAX --- src/platforms/GitHub/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platforms/GitHub/index.ts b/src/platforms/GitHub/index.ts index e2455fb..9f0e78f 100644 --- a/src/platforms/GitHub/index.ts +++ b/src/platforms/GitHub/index.ts @@ -163,8 +163,14 @@ export const GitHub: Platform = { return Boolean(URLHelper.isInPullPage()) }, getCurrentPath(branchName) { - if (URLHelper.parse().path.length) { - return DOMHelper.getPath() + const pathFromURL = URLHelper.parse().path.join('/') + if (pathFromURL.length) { + if (branchName && pathFromURL.startsWith(branchName + '/')) { + return pathFromURL.replace(branchName + '/', '').split('/') + } else { + // This would fail before PJAX replace, but works well when no branchName, e.g. first load + return DOMHelper.getPath() + } } else { return [] }