@@ -1085,7 +1085,7 @@ var formatTests = {
10851085
10861086 // `#`,`?` in path
10871087 '/path/to/%%23%3F+=&.txt?foo=theA1#bar' : {
1088- href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar' ,
1088+ href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar' ,
10891089 pathname : '/path/to/%#?+=&.txt' ,
10901090 query : {
10911091 foo : 'theA1'
@@ -1095,7 +1095,7 @@ var formatTests = {
10951095
10961096 // `#`,`?` in path + `#` in query
10971097 '/path/to/%%23%3F+=&.txt?foo=the%231#bar' : {
1098- href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar' ,
1098+ href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar' ,
10991099 pathname : '/path/to/%#?+=&.txt' ,
11001100 query : {
11011101 foo : 'the#1'
@@ -1110,7 +1110,7 @@ var formatTests = {
11101110 hostname : 'ex.com' ,
11111111 hash : '#frag' ,
11121112 search : '?abc=the#1?&foo=bar' ,
1113- pathname : '/foo?100%m#r' ,
1113+ pathname : '/foo?100%m#r'
11141114 } ,
11151115
11161116 // `?` and `#` in search only
@@ -1120,8 +1120,77 @@ var formatTests = {
11201120 hostname : 'ex.com' ,
11211121 hash : '#frag' ,
11221122 search : '?abc=the#1?&foo=bar' ,
1123- pathname : '/fooA100%mBr' ,
1123+ pathname : '/fooA100%mBr'
1124+ } ,
1125+
1126+ // path
1127+ 'http://github.com/joyent/node#js1' : {
1128+ href : 'http://github.com/joyent/node#js1' ,
1129+ protocol : 'http:' ,
1130+ hostname : 'github.com' ,
1131+ hash : '#js1' ,
1132+ path : '/joyent/node'
1133+ } ,
1134+
1135+ // pathname vs. path, path wins
1136+ 'http://github.com/joyent/node2#js1' : {
1137+ href : 'http://github.com/joyent/node2#js1' ,
1138+ protocol : 'http:' ,
1139+ hostname : 'github.com' ,
1140+ hash : '#js1' ,
1141+ path : '/joyent/node2' ,
1142+ pathname : '/joyent/node'
1143+ } ,
1144+
1145+ // pathname with query/search
1146+ 'http://github.com/joyent/node?foo=bar#js2' : {
1147+ href : 'http://github.com/joyent/node?foo=bar#js2' ,
1148+ protocol : 'http:' ,
1149+ hostname : 'github.com' ,
1150+ hash : '#js2' ,
1151+ path : '/joyent/node?foo=bar'
1152+ } ,
1153+
1154+ // path vs. query, path wins
1155+ 'http://github.com/joyent/node?foo=bar2#js3' : {
1156+ href : 'http://github.com/joyent/node?foo=bar2#js3' ,
1157+ protocol : 'http:' ,
1158+ hostname : 'github.com' ,
1159+ hash : '#js3' ,
1160+ path : '/joyent/node?foo=bar2' ,
1161+ query : { foo : 'bar' }
1162+ } ,
1163+
1164+ // path vs. search, path wins
1165+ 'http://github.com/joyent/node?foo=bar3#js4' : {
1166+ href : 'http://github.com/joyent/node?foo=bar3#js4' ,
1167+ protocol : 'http:' ,
1168+ hostname : 'github.com' ,
1169+ hash : '#js4' ,
1170+ path : '/joyent/node?foo=bar3' ,
1171+ search : '?foo=bar'
1172+ } ,
1173+
1174+ // path is present without ? vs. query given
1175+ 'http://github.com/joyent/node#js5' : {
1176+ href : 'http://github.com/joyent/node#js5' ,
1177+ protocol : 'http:' ,
1178+ hostname : 'github.com' ,
1179+ hash : '#js5' ,
1180+ path : '/joyent/node' ,
1181+ query : { foo : 'bar' }
1182+ } ,
1183+
1184+ // path is present without ? vs. search given
1185+ 'http://github.com/joyent/node#js6' : {
1186+ href : 'http://github.com/joyent/node#js6' ,
1187+ protocol : 'http:' ,
1188+ hostname : 'github.com' ,
1189+ hash : '#js6' ,
1190+ path : '/joyent/node' ,
1191+ search : '?foo=bar'
11241192 }
1193+
11251194} ;
11261195for ( var u in formatTests ) {
11271196 var expect = formatTests [ u ] . href ;
0 commit comments