File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -521,18 +521,24 @@ int hv_parse_url(hurl_t* stURL, const char* strURL) {
521521 if (ep == end ) return 0 ;
522522 // /path
523523 sp = ep ;
524- ep = strchr (sp , '?' );
525- if (ep == NULL ) ep = end ;
524+ const char * query = strchr (sp , '?' );
525+ const char * fragment = strchr (sp , '#' );
526+ if (query && fragment ) ep = MIN (query , fragment );
527+ else if (query == NULL && fragment ) ep = fragment ;
528+ else if (query == NULL ) ep = end ;
529+ else ep = query ;
526530 stURL -> fields [HV_URL_PATH ].off = sp - begin ;
527531 stURL -> fields [HV_URL_PATH ].len = ep - sp ;
528532 if (ep == end ) return 0 ;
529- // ?query
530- sp = ep + 1 ;
531- ep = strchr (sp , '#' );
532- if (ep == NULL ) ep = end ;
533- stURL -> fields [HV_URL_QUERY ].off = sp - begin ;
534- stURL -> fields [HV_URL_QUERY ].len = ep - sp ;
535- if (ep == end ) return 0 ;
533+ if (ep != fragment ) {
534+ // ?query
535+ sp = ep + 1 ;
536+ ep = fragment ;
537+ if (ep == NULL ) ep = end ;
538+ stURL -> fields [HV_URL_QUERY ].off = sp - begin ;
539+ stURL -> fields [HV_URL_QUERY ].len = ep - sp ;
540+ if (ep == end ) return 0 ;
541+ }
536542 // #fragment
537543 sp = ep + 1 ;
538544 ep = end ;
You can’t perform that action at this time.
0 commit comments