jacketizer / libyuarel Goto Github PK
View Code? Open in Web Editor NEWSimple C library for parsing URLs with zero-copy and no mallocs.
Home Page: http://yuarel.org
License: MIT License
Simple C library for parsing URLs with zero-copy and no mallocs.
Home Page: http://yuarel.org
License: MIT License
An absolute path without host should be a valid url. Unfortunately yuerel_parse() fails in this case.
Hi!
I tried this library in my Lwip stm32f4 webserver project, it works fine but if add user name/password, then not work, I think need modification for making it work with example mentioned below
"http://admin:[email protected]:8989/path/to/test?query=yes¶m1=no#frag=1"
Nitpicking ;)
The README.md ("How to use it") is missing the definition of params
:
struct yuarel_param params[3];
otherwise it won't compile.
Hi,
This is not really a problem for my case, but I'm reporting it just FYI.
http://[2001:4860:0:2001::68]/foo/bar?a=123
Struct values:
scheme: http
host: [2001
port: 574336293
path: foo/bar
query: a=123
fragment: (null)
Could not split path!
Hello, I found an error when 1 struct yuarel_param is passed to the yuarel_parse_query() function.
They are not working properly.
char* query = "a=b&c=d";
yuarel_param params;
yuarel_parse_query(query, '&', ¶ms, 1);
// HERE
// params.key == "a"
// params.val == "b&c=d"
Hi, thanks for sharing your code! I'm dumping a one-off parser I wrote myself in another project for yours.
One issue I found is it seems the code that parses credentials requires both user and password.
E.g. http://u:[email protected]
works, but http://[email protected]
does not.
Does this look like the right fix?
diff --git a/yuarel.c b/yuarel.c
index a5f313fb7..072bd76ad 100644
--- a/yuarel.c
+++ b/yuarel.c
@@ -180,12 +180,11 @@ yuarel_parse(struct yuarel *url, char *u)
*u = '\0';
u = strchr(url->username, ':');
- if (NULL == u) {
- return -1;
+ if (NULL != u) {
+ url->password = u + 1;
+ *u = '\0';
}
- url->password = u + 1;
- *u = '\0';
}
/* Missing hostname? */
Maybe the Read.me could be updated with the notion that the original string will be modified during the parsing proces?
I noticed my original string after parsing containing only "http" after parsing was done. I still need my original string after parsing, so I pulled a copy using malloc().
I assume you do not want a malloc() call in your lib? So you deliberately do not make a local copy, am I right?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.