lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Unintended add '/' to the end in URL after upgrading v9 (PageSpeed Insights) #13373

Open toanbku opened this issue 5 years ago • 7 comments

FAQ

  • [X] Yes, my issue is not about variability or throttling.
  • [X] Yes, my issue is not about a specific accessibility audit (file with axe-core instead).

URL

https://pagespeed.web.dev/report?url=https%3A%2F%2Fwww.google.com

What happened?

Follow these URLs:

  • https://pagespeed.web.dev/report?url=https%3A%2F%2Fwww.google.com
  • https://pagespeed.web.dev/report?url=https%3A%2F%2Fwww.google.com%2F

It is quite different, but when entering it, the URL at the box of the pagespeed insight is the same (always have the '/' in the end) image

This thing is never happening on v7 or v8.

What did you expect?

Keep the same behavior as previous version

What have you tried?

No response

How were you running Lighthouse?

PageSpeed Insights

Lighthouse Version

v9.0.0

Chrome Version

No response

Node Version

No response

OS

No response

Relevant log output

No response

toanbku avatar Nov 16 '21 04:11 toanbku

Trailing slashes after the domain shouldn't matter so https://www.google.com is the same as https://www.google.com/.

PSI does not force a trailing slash when it does identify a different URL (e.g. https://web.dev/learn-web-vitals vs https://web.dev/learn-web-vitals/). I think this is WAI.

adamraine avatar Nov 16 '21 17:11 adamraine

We have two different places that normalize URLs. And one of them conditionally adds a trailing slash while the other doesn't.

We should make them operate consistently.

Agree with adam that it probably doesn't make a material difference, but since we're getting picky about URLs we should be consistent ourselves.

paulirish avatar Nov 16 '21 18:11 paulirish

Hi @adamraine, @paulirish

With these websites that use Next.js, by default, it will redirect if the URL has trailing '/'. For more detail, please visit the document: https://nextjs.org/docs/api-reference/next.config.js/trailing-slash

Because of redirecting, the URL has trailing '/' have the LOWER score than the URL not having trailing '/'

So please keep the lighthouse the same behavior as the previous version

toanbku avatar Nov 17 '21 01:11 toanbku

Please see the screenshot below

Pasted_Image_17_11_2021__09_03

toanbku avatar Nov 17 '21 02:11 toanbku

I had the same misunderstanding you did: yes, https://nextjs.org/docs/api-reference/next.config.js/trailing-slash is a different url from https://nextjs.org/docs/api-reference/next.config.js/trailing-slash/, but https://nextjs.org does not exist [1]. You can do new URL('https://nextjs.org').href (or .pathname) to see that the url path is normalized to be at least /, and can never be an empty string.

If you type https://nextjs.org/docs/api-reference/next.config.js/trailing-slash in the input box in pagespeed you will see we do not add a slash.

[1] Probably more accurate to say it is normalized. context

connorjclark avatar Nov 17 '21 06:11 connorjclark

Fix (internal): cl/410531354

jazyan avatar Nov 17 '21 19:11 jazyan

This should be fixed, eg https://pagespeed.web.dev/report?url=https://nextjs.org/docs/api-reference/next.config.js/trailing-slash no longer appends a trailing slash to the URL, but feel free to reopen if there's anything missed.

jazyan avatar Nov 18 '21 15:11 jazyan