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

[URL validation bug] : url's without 'http'/'https' returns LHError #94

Open
3 tasks done
Neilblaze opened this issue Dec 23, 2021 · 0 comments
Open
3 tasks done

Comments

@Neilblaze
Copy link

Description

The default cmd lighthouse-ci <URL> only returns score(s) when the URL is totally validated. But returns LHError when a non-validated URL is passed as an input.

What is the current behavior?

  • For example, let's say if you try,
lighthouse-ci https://neilblaze.live

it'll pass all the checks & return the successful response with the metrics. But, if you try this,

lighthouse-ci neilblaze.live

it'll return LHError! ⚠️

recording

Checks out, it does work with validated sub-domains too, but not with the unvalidated ones.

  • Even, if you exclude 'www', it returns the same (LHError).

image

image

⚠️ Note : Subdomains don't work with "www" prepended! This test was done for example purposes.

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • What is the expected behavior?

The non-validated URL's should auto-converted into valid ones to make the check pass & return the metrics. I did explore the codebase & I'm trying to figure out where from the cmd-line input is being taken as a string.

I'm suggesting a method as follows,

rootStatement = "Lorem ipsum dolor sit amet, magna aliqua. Visit www.neilblaze.live for regular updates. Duis aute irure $ dolor in cupidatat @ non proident.";

// 💡 rootStatement is the dummy input 

function detectURLs(message) {
  var urlRgx = /(((https?:\/\/)|(www\.))[^\s]+)/g;
  // ⚠️ url check without http/https & www is also possible, but in that case, it'll only work with TLD's, hence ignored
  return message.match(urlRgx)
}
 
link = detectURLs(rootStatement); // Old URL
linkx = (link.indexOf('://') === -1) ? 'http://' + link : link; // http is auto redirected to https if SSL enabled

// Now replacing the new URL (with all validation check parameters) in the place of the URL string (without parameters)

finalLink = rootStatement.replace(link, linkx);
// console.log(finalLink) // Debug purposes

From here, we just need to pass the finalLink into the root 🚀

  • What is the motivation / use case for changing the behavior?
    I personally use this project a lot & I want to improve the overall experience 😄

  • Please tell us about your environment:

    • Browser: Chrome [Version 96.0.4664.110 (Official Build) (64-bit)]
    • OS : Windows 10 [64bit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant