X Tutup
The Wayback Machine - https://web.archive.org/web/20201009212230/https://github.com/github/docs/issues/316
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homepage calculation gives bad URLs on Windows #316

Open
jeffmcaffer opened this issue Oct 9, 2020 · 0 comments · May be fixed by #351
Open

homepage calculation gives bad URLs on Windows #316

jeffmcaffer opened this issue Oct 9, 2020 · 0 comments · May be fixed by #351

Comments

@jeffmcaffer
Copy link
Contributor

@jeffmcaffer jeffmcaffer commented Oct 9, 2020

What is the current behavior?

Three of the tests related to homepage calculation. The are all of the following flavor.

FAIL  tests/rendering/header.js (66.489 s)
  ● header › mobile-only product dropdown links › include github and admin, and emphasize the current product

    expect(received).toBe(expected) // Object.is equality

    Expected: 1
    Received: 0

      72 |
      73 |       const github = $(`#homepages a.active[href="/en/${nonEnterpriseDefaultVersion}/github"]`)
    > 74 |       expect(github.length).toBe(1)
         |                             ^
      75 |       expect(github.text().trim()).toBe('GitHub.com')
      76 |       expect(github.attr('class').includes('active')).toBe(true)
      77 |

      at Object.<anonymous> (tests/rendering/header.js:74:29)

and here is a sample of the HTML being returned from get. As you can see, Windows path separators () are being used indicating that path.join is likely involved. I've not isolated the particular code as yet.

        class=\"position-md-absolute nav-desktop-productDropdown p-md-4 left-md-n4
        top-md-6\" style=\"z-index: 6;\">\r\n \r\n <a
            href=\"/en\\free-pro-team@latest\\github\"\r\n class=\"d-block py-2\r\n
            text-blue-mktg text-underline active\">\r\n GitHub.com\r\n \r\n </a>\r\n
        \r\n <a href=\"/en\\enterprise-server@2.22\\admin\"\r\n class=\"d-block
            py-2\r\n link-gray-dark no-underline\">\r\n Enterprise
            Administrators\r\n \r\n </a>\r\n \r\n <a
            href=\"/en\\free-pro-team@latest\\actions\"\r\n class=\"d-block py-2\r\n
            link-gray-dark no-underline\">\r\n GitHub Actions\r\n \r\n </a>\r\n \r\n
        <a href=\"/en\\free-pro-team@latest\\packages\"\r\n class=\"d-block py-2\r\n

What changes are you suggesting?

Suggest we do an audit of all the places that inject URLs into content or headers and ensure they don't use path.join. In fact, we should make a helper (e.g., safeJoin) that does something like (...segments) => slash(path.join(segments)) and then use that everywhere that has anything to do with web results.

cc @github/docs-engineering , @chiedo

@github-actions github-actions bot added the triage label Oct 9, 2020
@github-actions github-actions bot added this to Triage in Docs team reviews Oct 9, 2020
@zeke zeke added the windows label Oct 9, 2020
@janiceilene janiceilene moved this from Triage to Engineering in Docs team reviews Oct 9, 2020
@janiceilene janiceilene removed the triage label Oct 9, 2020
@jeffmcaffer jeffmcaffer linked a pull request that will close this issue Oct 9, 2020
0 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.
X Tutup