Comments (9)
I mean, it just does what it says in the README, so as long as that is your use case, then that's what it is for. It was my use-case at least. If you don't need to use this and want to use the built in encoding functions, I have no objections. I just made it for my use cade and put it out there if anyone else neede to use it, but I am not forcing anyone to use it if the built in functions work for them.
from encodeurl.
The encoding this module does most closely matches how the URL
constructor works, though was available before URL
was added to Node.js (and just works on strings without needing to construct a URL
instance). My main use case was to take a URL that one could enter into the web browser location bar and encode it to ASCII-only for putting in to a HTTP header value. The URL
constructor does this now, though it has some extra validations and doesn't do a few things like encode %
that is not part of a valid sequence (I based this off encodeURI
which always encodes the %
).
from encodeurl.
Thanks for the explanation.
I will stick to using URL
then.
Maybe it would be worth mentioning using URL in the README instead?
from encodeurl.
Yea, I can do that. What should it say, exactly? I am not familiar with the exact URL
algorithm since this was not based on it, instead it was based on encodeURL
. Just from some light testing they this module doesn't work exactly the same, so probably would need to list out how it is different, just like how it mentions encodeURI
and what the differences are between thos module and that.
from encodeurl.
I am not familiar with the exact URL algorithm
Me neither 😅
Maybe that URL could handle Punycode as well? (unlike other solutions?)
What should it say, exactly?
I don't know, Perhaps something like:
**Note** You might not need this anymore. I created this before `URL` was shipped to NodeJS
URL exist pretty much in every env now days and dose pretty much the same thing.
So you might be fine with just using the `URL` constructor instead.
Do note however that there are some noticeable differences between this `encodeurl` package and URL constructor.
- `URL` can handle punycode
- something something something.
from encodeurl.
Yea, would need to actually figure out the something something something
before I add anything to the README otherwise it will just lead to more confusion. I only just looked in to the URL
constructor after your issue was made and noticed they seemed to maybe be the same? I really don't know all the details and if it is possible to move. Just using this module's own tests as a guide it seems to be different in a bunch of ways. This module was just me fixing encodeURI
to be what I wanted; it was not made in order to backport URL
constructor encoding or anything, as I wasn't even aware of that until just today, so that normative seems misleading to include, as it would imply that this module was some how supposed to be like URL
, though it wasn't. I'm very much not comfortable stating in the README that it "dose pretty much the same thing" because I have no idea is that is true without actually looking at the algorithm.
Edit: for punycode, yea, this module doesn't do that, just like encodeURI
(which is what this module is based on).
Edit edit: the more I am digging in to the URL
constructor, the more and more differences there seems to be. I don't think the URL
constructor is a direct replacement for this module if you actually want this module, at least not without writing a bunch of code on top of the URI
usage to mold it. So at best it should just say exactly how it is different, not state to use one over the other, as they don't work the same way.
from encodeurl.
So at best it should just say exactly how it is different, not state to use one over the other, as they don't work the same way.
if that's the case. then yea maybe it would be better to highlight the differences. i just suggested it cuz you said
"The encoding this module does most closely matches how the URL constructor works"
Could also mention that URL
is only available in NodeJS v10+
Some known ports get stripped out for normalization
new URL('https://localhost:443')+'' // https://localhost
new URL('http://localhost:80')+'' // http://localhost
from encodeurl.
Yea, sorry, it is a holiday here so I am mostly mobile and when i first looked at URL
constructor it, at the time of my comment, did seem to most closely match it. But as I have been digging in, there are actually more differences between this module and the URL constructor than this module and encodeURI function. Seems like there are a LOT of differences between this and URL constructor in fact. Seems you gound yet another one. I was probably incorrect to suggest the URL constructor as an alternative in my comment, I apologize, I was misunderstanding the URL constructor.
from encodeurl.
That's alright.
I'm not going to push you any further to suggest to folks that they should change to using URL
instead and that you change the README
What you decide to do or not do is up to you.
I only wanted to know the reasoning behind why the need for this package exist.
Only wanted to know if this would bring me any usefulness into my own application / library.
Enjoy your holiday 👋
from encodeurl.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from encodeurl.