Skip to content

[fix] Invalid protocols are matched #31

Open
@ghost

Description

Describe the bug

Node.js version: v18.18.2

OS version: macOS 14.2.1

Description: If a valid protocol has extra characters preceding it, the extra characters are included in the match.

Actual behavior

urlRegexSafe({ strict: true }).exec("gaewggwhttp://localhost:3000/derp")

Produces a match that contains the entire string, including "gaewgg".

This also happens when strict is set to false.

Expected behavior

The match that is produced does not include "gaewgg"

Code to reproduce

const urlRegexSafe = require('url-regex-safe')
const match = urlRegexSafe({ strict: true }).exec("gaewggwhttp://localhost:3000/derp")
console.log(match)

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions