sindresorhus / normalize-url

Normalize a URL
MIT License
837 stars 123 forks source link

Strip ftp:// and ssh:// #159

Closed ozgurg closed 2 years ago

ozgurg commented 2 years ago

I accidentally pressed ENTER while creating the issue. 😄

Is it possible to strip ftp:// and ssh://?

I tried these options but it didn't worked. Actually I want strip all protocols.

defaultProtocol: "ftp:",
stripProtocol: true,
normalizeProtocol: true
sindresorhus commented 2 years ago

It only strips protocol for http: and https:. I should make that clearer in the docs. Stripping any protocol would make the URL become ambiguous. Why are you trying to do this?

ozgurg commented 2 years ago

It only strips protocol for http: and https:. I should make that clearer in the docs. Stripping any protocol would make the URL become ambiguous. Why are you trying to do this?

I get the URL from an input, and it might contains ftp:// and ssh:// (and other protocols). So I want to strip all protocols. I would replace them with empty string but I wanted to know if the library can do this. If this isn't the target of the library, I'm OK with that.

By the way I agree with you in making that clearer in the docs.

sindresorhus commented 2 years ago

That's not a good use for this package. You can just use a simple regex instead. Docs improved.