@@ -1085,7 +1085,7 @@ var formatTests = {
1085
1085
1086
1086
// `#`,`?` in path
1087
1087
'/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' ,
1089
1089
pathname : '/path/to/%#?+=&.txt' ,
1090
1090
query : {
1091
1091
foo : 'theA1'
@@ -1095,7 +1095,7 @@ var formatTests = {
1095
1095
1096
1096
// `#`,`?` in path + `#` in query
1097
1097
'/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' ,
1099
1099
pathname : '/path/to/%#?+=&.txt' ,
1100
1100
query : {
1101
1101
foo : 'the#1'
@@ -1110,7 +1110,7 @@ var formatTests = {
1110
1110
hostname : 'ex.com' ,
1111
1111
hash : '#frag' ,
1112
1112
search : '?abc=the#1?&foo=bar' ,
1113
- pathname : '/foo?100%m#r' ,
1113
+ pathname : '/foo?100%m#r'
1114
1114
} ,
1115
1115
1116
1116
// `?` and `#` in search only
@@ -1120,8 +1120,77 @@ var formatTests = {
1120
1120
hostname : 'ex.com' ,
1121
1121
hash : '#frag' ,
1122
1122
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'
1124
1192
}
1193
+
1125
1194
} ;
1126
1195
for ( var u in formatTests ) {
1127
1196
var expect = formatTests [ u ] . href ;
0 commit comments