Changeset 248895 in webkit
- Timestamp:
- Aug 20, 2019 12:04:02 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248894 r248895 1 2019-08-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Use URL constructor to better handle all kinds of URLs 4 https://bugs.webkit.org/show_bug.cgi?id=165155 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/unit-tests/url-utilities.html: 9 * inspector/unit-tests/url-utilities-expected.txt: 10 1 11 2019-08-19 Devin Rousso <drousso@apple.com> 2 12 -
trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt
r248774 r248895 17 17 PASS: port should be: 'null' 18 18 PASS: origin should be: 'http://example.com' 19 PASS: path should be: ' null'19 PASS: path should be: '/' 20 20 PASS: queryString should be: 'null' 21 21 PASS: fragment should be: 'null' … … 37 37 PASS: userinfo should be: 'null' 38 38 PASS: host should be: 'example.com' 39 PASS: port should be: '80' 40 PASS: origin should be: 'http://example.com:80' 39 PASS: port should be: 'null' 40 PASS: origin should be: 'http://example.com' 41 PASS: path should be: '/' 42 PASS: queryString should be: 'null' 43 PASS: fragment should be: 'null' 44 PASS: lastPathComponent should be: 'null' 45 46 Test Valid: http://example.com:42/ 47 PASS: scheme should be: 'http' 48 PASS: userinfo should be: 'null' 49 PASS: host should be: 'example.com' 50 PASS: port should be: '42' 51 PASS: origin should be: 'http://example.com:42' 41 52 PASS: path should be: '/' 42 53 PASS: queryString should be: 'null' … … 62 73 PASS: origin should be: 'http://example.com' 63 74 PASS: path should be: '/path/to/page.html' 64 PASS: queryString should be: ' '75 PASS: queryString should be: 'null' 65 76 PASS: fragment should be: 'null' 66 77 PASS: lastPathComponent should be: 'page.html' … … 127 138 PASS: port should be: 'null' 128 139 PASS: origin should be: 'http://example.com' 129 PASS: path should be: ' null'140 PASS: path should be: '/' 130 141 PASS: queryString should be: 'null' 131 142 PASS: fragment should be: 'alpha/beta' … … 149 160 PASS: port should be: 'null' 150 161 PASS: origin should be: 'http://example' 151 PASS: path should be: ' null'162 PASS: path should be: '/' 152 163 PASS: queryString should be: 'null' 153 164 PASS: fragment should be: 'null' … … 160 171 PASS: port should be: 'null' 161 172 PASS: origin should be: 'http://my.example.com' 162 PASS: path should be: ' null'173 PASS: path should be: '/' 163 174 PASS: queryString should be: 'null' 164 175 PASS: fragment should be: 'null' … … 176 187 PASS: lastPathComponent should be: 'null' 177 188 178 -- Known issues <https://webkit.org/b/165155>179 180 189 Test Invalid: http:// 181 FAIL: Should not be a complete URL 182 Expected: truthy 183 Actual: false 190 PASS: Should not be a complete URL 184 191 PASS: URL constructor thinks this is invalid 185 192 186 Test Invalid: http://example.com:999999999 187 FAIL: Should not be a complete URL 188 Expected: truthy 189 Actual: false 193 Test Invalid: http://example.com:65537 194 PASS: Should not be a complete URL 190 195 PASS: URL constructor thinks this is invalid 191 196 192 197 Test Valid: http:example.com/ 193 FAIL: scheme should be: 'http' 194 Expected: "http" 195 Actual: null 196 PASS: userinfo should be: 'null' 197 FAIL: host should be: 'example.com' 198 Expected: "example.com" 199 Actual: null 200 PASS: port should be: 'null' 201 FAIL: origin should be: 'http://example.com' 202 Expected: "http://example.com" 203 Actual: null 204 FAIL: path should be: '/' 205 Expected: "/" 206 Actual: null 198 PASS: scheme should be: 'http' 199 PASS: userinfo should be: 'null' 200 PASS: host should be: 'example.com' 201 PASS: port should be: 'null' 202 PASS: origin should be: 'http://example.com' 203 PASS: path should be: '/' 207 204 PASS: queryString should be: 'null' 208 205 PASS: fragment should be: 'null' … … 210 207 211 208 Test Valid: http:/example.com/ 212 FAIL: scheme should be: 'http' 213 Expected: "http" 214 Actual: null 215 PASS: userinfo should be: 'null' 216 FAIL: host should be: 'example.com' 217 Expected: "example.com" 218 Actual: null 219 PASS: port should be: 'null' 220 FAIL: origin should be: 'http://example.com' 221 Expected: "http://example.com" 222 Actual: null 223 FAIL: path should be: '/' 224 Expected: "/" 225 Actual: null 209 PASS: scheme should be: 'http' 210 PASS: userinfo should be: 'null' 211 PASS: host should be: 'example.com' 212 PASS: port should be: 'null' 213 PASS: origin should be: 'http://example.com' 214 PASS: path should be: '/' 226 215 PASS: queryString should be: 'null' 227 216 PASS: fragment should be: 'null' … … 239 228 PASS: lastPathComponent should be: 'null' 240 229 241 Test Valid: http://user@pass:example.com/ 242 FAIL: scheme should be: 'http' 243 Expected: "http" 244 Actual: null 245 PASS: userinfo should be: 'null' 246 FAIL: host should be: 'example.com' 247 Expected: "example.com" 248 Actual: null 249 PASS: port should be: 'null' 250 FAIL: origin should be: 'http://example.com' 251 Expected: "http://example.com" 252 Actual: null 253 FAIL: path should be: '/' 254 Expected: "/" 255 Actual: null 256 PASS: queryString should be: 'null' 257 PASS: fragment should be: 'null' 258 PASS: lastPathComponent should be: 'null' 230 Test Valid: http://:pass@example.com/ 231 PASS: scheme should be: 'http' 232 PASS: userinfo should be: ':pass' 233 PASS: host should be: 'example.com' 234 PASS: port should be: 'null' 235 PASS: origin should be: 'http://example.com' 236 PASS: path should be: '/' 237 PASS: queryString should be: 'null' 238 PASS: fragment should be: 'null' 239 PASS: lastPathComponent should be: 'null' 240 241 Test Invalid: http://user@pass:example.com/ 242 PASS: Should not be a complete URL 243 PASS: URL constructor thinks this is invalid 259 244 260 245 Test Valid: http://example.com?key=alpha/beta 261 246 PASS: scheme should be: 'http' 262 247 PASS: userinfo should be: 'null' 263 FAIL: host should be: 'example.com' 264 Expected: "example.com" 265 Actual: "example.com?key=alpha" 266 PASS: port should be: 'null' 267 FAIL: origin should be: 'http://example.com' 268 Expected: "http://example.com" 269 Actual: "http://example.com?key=alpha" 270 FAIL: path should be: 'null' 271 Expected: null 272 Actual: "/beta" 273 FAIL: queryString should be: 'key=alpha/beta' 274 Expected: "key=alpha/beta" 275 Actual: null 276 PASS: fragment should be: 'null' 277 FAIL: lastPathComponent should be: 'null' 278 Expected: null 279 Actual: "beta" 248 PASS: host should be: 'example.com' 249 PASS: port should be: 'null' 250 PASS: origin should be: 'http://example.com' 251 PASS: path should be: '/' 252 PASS: queryString should be: 'key=alpha/beta' 253 PASS: fragment should be: 'null' 254 PASS: lastPathComponent should be: 'null' 280 255 281 256 -- Running test case: parseDataURL … … 381 356 382 357 -- Running test case: WI.displayNameForURL 383 PASS: Display name of 'a' should be 'a'.384 PASS: Display name of 'http://' should be 'http://'.385 358 PASS: Display name of 'http://example' should be 'example'. 386 359 PASS: Display name of 'http://example.com' should be 'example.com'. 387 360 PASS: Display name of 'http://example.com/' should be 'example.com'. 388 PASS: Display name of 'http://example.com:999999999' should be 'example.com'.389 361 PASS: Display name of 'http://example.com:80/' should be 'example.com'. 362 PASS: Display name of 'http://example.com:42/' should be 'example.com'. 390 363 PASS: Display name of 'http://example.com/path' should be 'path'. 391 364 PASS: Display name of 'http://example.com/path/' should be 'path'. … … 402 375 PASS: Display name of 'http://example.com/#foo%20bar' should be 'example.com'. 403 376 PASS: Display name of 'http://example.com/foo%20bar' should be 'foo bar'. 377 PASS: Display name of 'http://example.com?key=foo%20bar' should be 'example.com'. 404 378 PASS: Display name of 'http://example.com/?key=foo%20bar' should be 'example.com'. 379 PASS: Display name of 'http://example.com?key=foo bar' should be 'example.com'. 380 PASS: Display name of 'http://example.com/?key=foo bar' should be 'example.com'. 405 381 PASS: Display name of 'http://example.com/foo%20bar' should be 'foo bar'. 406 382 PASS: Display name of 'http://example.com/foo bar' should be 'foo bar'. … … 409 385 PASS: Display name of 'http://example.com#foo%2Fbar' should be 'example.com'. 410 386 PASS: Display name of 'http://example.com/#foo%2Fbar' should be 'example.com'. 387 PASS: Display name of 'http://example.com?key=foo%2Fbar' should be 'example.com'. 411 388 PASS: Display name of 'http://example.com/?key=foo%2Fbar' should be 'example.com'. 389 PASS: Display name of 'http://example.com?key=foo/bar' should be 'example.com'. 390 PASS: Display name of 'http://example.com/?key=foo/bar' should be 'example.com'. 412 391 PASS: Display name of 'http://example.com/foo%2Fbar' should be 'foo/bar'. 413 392 PASS: Display name of 'http://user:pass@example.com/' should be 'example.com'. 393 PASS: Display name of 'http://:pass@example.com/' should be 'example.com'. 414 394 PASS: Display name of 'http://my.example.com' should be 'my.example.com'. 415 395 PASS: Display name of 'http://my.example.com/' should be 'my.example.com'. … … 423 403 PASS: Display name of 'app-specific://example.com/' should be 'example.com'. 424 404 PASS: Display name of 'app-specific://example.com/path' should be 'path'. 425 426 Allowing directory as name...427 405 PASS: Display name of 'a' should be 'a'. 428 406 PASS: Display name of 'http://' should be 'http://'. 429 PASS: Display name of 'http://example' should be 'example'. 430 PASS: Display name of 'http://example.com' should be 'example.com'. 407 PASS: Display name of 'http://example.com:65537' should be 'http://example.com:65537'. 408 PASS: Display name of 'http://user@pass:example.com/' should be 'http://user@pass:example.com/'. 409 410 Allowing directory as name... 411 PASS: Display name of 'http://example' should be '/'. 412 PASS: Display name of 'http://example.com' should be '/'. 431 413 PASS: Display name of 'http://example.com/' should be '/'. 432 PASS: Display name of 'http://example.com:999999999' should be 'example.com'.433 414 PASS: Display name of 'http://example.com:80/' should be '/'. 415 PASS: Display name of 'http://example.com:42/' should be '/'. 434 416 PASS: Display name of 'http://example.com/path' should be 'path'. 435 417 PASS: Display name of 'http://example.com/path/' should be '/'. … … 443 425 PASS: Display name of 'http://example.com/path/to/page.html?a=1&b=foo%2Fbar#test' should be 'page.html'. 444 426 PASS: Display name of 'http://example.com:123/path/to/page.html?a=1&b=foo%2Fbar#test' should be 'page.html'. 445 PASS: Display name of 'http://example.com#foo%20bar' should be ' example.com'.427 PASS: Display name of 'http://example.com#foo%20bar' should be '/'. 446 428 PASS: Display name of 'http://example.com/#foo%20bar' should be '/'. 447 429 PASS: Display name of 'http://example.com/foo%20bar' should be 'foo bar'. 430 PASS: Display name of 'http://example.com?key=foo%20bar' should be '/'. 448 431 PASS: Display name of 'http://example.com/?key=foo%20bar' should be '/'. 432 PASS: Display name of 'http://example.com?key=foo bar' should be '/'. 433 PASS: Display name of 'http://example.com/?key=foo bar' should be '/'. 449 434 PASS: Display name of 'http://example.com/foo%20bar' should be 'foo bar'. 450 435 PASS: Display name of 'http://example.com/foo bar' should be 'foo bar'. 451 PASS: Display name of 'http://example.com#foo/bar' should be ' example.com'.436 PASS: Display name of 'http://example.com#foo/bar' should be '/'. 452 437 PASS: Display name of 'http://example.com/#foo/bar' should be '/'. 453 PASS: Display name of 'http://example.com#foo%2Fbar' should be ' example.com'.438 PASS: Display name of 'http://example.com#foo%2Fbar' should be '/'. 454 439 PASS: Display name of 'http://example.com/#foo%2Fbar' should be '/'. 440 PASS: Display name of 'http://example.com?key=foo%2Fbar' should be '/'. 455 441 PASS: Display name of 'http://example.com/?key=foo%2Fbar' should be '/'. 442 PASS: Display name of 'http://example.com?key=foo/bar' should be '/'. 443 PASS: Display name of 'http://example.com/?key=foo/bar' should be '/'. 456 444 PASS: Display name of 'http://example.com/foo%2Fbar' should be 'foo/bar'. 457 445 PASS: Display name of 'http://user:pass@example.com/' should be '/'. 458 PASS: Display name of 'http://my.example.com' should be 'my.example.com'. 446 PASS: Display name of 'http://:pass@example.com/' should be '/'. 447 PASS: Display name of 'http://my.example.com' should be '/'. 459 448 PASS: Display name of 'http://my.example.com/' should be '/'. 460 449 PASS: Display name of 'file:///foo' should be 'foo'. … … 467 456 PASS: Display name of 'app-specific://example.com/' should be '/'. 468 457 PASS: Display name of 'app-specific://example.com/path' should be 'path'. 469 470 -- Known issues <https://webkit.org/b/165155> 471 472 FAIL: Display name of 'http://example.com?key=foo%2Fbar' should be 'example.com'. 473 Expected: "example.com" 474 Actual: "example.com?key=foo%2fbar" 475 FAIL: Display name of 'http://example.com?key=foo/bar' should be 'example.com'. 476 Expected: "example.com" 477 Actual: "bar" 478 FAIL: Display name of 'http://example.com?key=foo%20bar' should be 'example.com'. 479 Expected: "example.com" 480 Actual: "example.com?key=foo%20bar" 481 FAIL: Display name of 'http://example.com?key=foo bar' should be 'example.com'. 482 Expected: "example.com" 483 Actual: "example.com?key=foo bar" 484 485 Allowing directory as name... 486 FAIL: Display name of 'http://example.com?key=foo%2Fbar' should be 'example.com'. 487 Expected: "example.com" 488 Actual: "example.com?key=foo%2fbar" 489 FAIL: Display name of 'http://example.com?key=foo/bar' should be 'example.com'. 490 Expected: "example.com" 491 Actual: "bar" 492 FAIL: Display name of 'http://example.com?key=foo%20bar' should be 'example.com'. 493 Expected: "example.com" 494 Actual: "example.com?key=foo%20bar" 495 FAIL: Display name of 'http://example.com?key=foo bar' should be 'example.com'. 496 Expected: "example.com" 497 Actual: "example.com?key=foo bar" 458 PASS: Display name of 'a' should be 'a'. 459 PASS: Display name of 'http://' should be 'http://'. 460 PASS: Display name of 'http://example.com:65537' should be 'http://example.com:65537'. 461 PASS: Display name of 'http://user@pass:example.com/' should be 'http://user@pass:example.com/'. 498 462 499 463 -- Running test case: WI.h2Authority … … 513 477 PASS: HTTP/2 :authority of 'http://user:pass@example.com:123/foo' should be 'example.com:123'. 514 478 PASS: HTTP/2 :authority of 'https://user:pass@example.com:123/foo' should be 'example.com:123'. 479 PASS: HTTP/2 :authority of 'ftp://:pass@example.com/foo' should be ':pass@example.com'. 480 PASS: HTTP/2 :authority of 'http://:pass@example.com/foo' should be 'example.com'. 481 PASS: HTTP/2 :authority of 'https://:pass@example.com/foo' should be 'example.com'. 482 PASS: HTTP/2 :authority of 'ftp://:pass@example.com:123/foo' should be ':pass@example.com:123'. 483 PASS: HTTP/2 :authority of 'http://:pass@example.com:123/foo' should be 'example.com:123'. 484 PASS: HTTP/2 :authority of 'https://:pass@example.com:123/foo' should be 'example.com:123'. 515 485 516 486 -- Running test case: WI.h2Path 517 487 PASS: HTTP/2 :path of 'http://example.com' should be '/'. 518 488 PASS: HTTP/2 :path of 'https://example.com' should be '/'. 519 PASS: HTTP/2 :path of 'ftp://example.com' should be ' '.489 PASS: HTTP/2 :path of 'ftp://example.com' should be '/'. 520 490 PASS: HTTP/2 :path of 'http://example.com/foo' should be '/foo'. 521 491 PASS: HTTP/2 :path of 'https://example.com/foo' should be '/foo'. -
trunk/LayoutTests/inspector/unit-tests/url-utilities.html
r248774 r248895 14 14 InspectorTest.log(""); 15 15 InspectorTest.log("Test Invalid: " + url); 16 InspectorTest.expectThat(parseURL(url).scheme === null, "Should not be a complete URL"); 16 17 let urlComponents = parseURL(url); 18 InspectorTest.expectNull(urlComponents.scheme, "Should not be a complete URL"); 19 if (urlComponents.scheme) 20 InspectorTest.json(urlComponents); 17 21 18 22 try { … … 51 55 port: null, 52 56 origin: "http://example.com", 53 path: null,57 path: "/", 54 58 queryString: null, 55 59 fragment: null, … … 73 77 userinfo: null, 74 78 host: "example.com", 75 port: 80, 76 origin: "http://example.com:80", 79 port: null, 80 origin: "http://example.com", 81 path: "/", 82 queryString: null, 83 fragment: null, 84 lastPathComponent: null, 85 }); 86 87 testValid("http://example.com:42/", { 88 scheme: "http", 89 userinfo: null, 90 host: "example.com", 91 port: 42, 92 origin: "http://example.com:42", 77 93 path: "/", 78 94 queryString: null, … … 100 116 origin: "http://example.com", 101 117 path: "/path/to/page.html", 102 queryString: "",118 queryString: null, 103 119 fragment: null, 104 120 lastPathComponent: "page.html", … … 171 187 port: null, 172 188 origin: "http://example.com", 173 path: null,189 path: "/", 174 190 queryString: null, 175 191 fragment: "alpha/beta", … … 195 211 port: null, 196 212 origin: "http://example", 197 path: null,213 path: "/", 198 214 queryString: null, 199 215 fragment: null, … … 207 223 port: null, 208 224 origin: "http://my.example.com", 209 path: null,225 path: "/", 210 226 queryString: null, 211 227 fragment: null, … … 226 242 }); 227 243 228 // FIXME: <https://webkit.org/b/165155> Web Inspector: Use URL constructor to better handle all kinds of URLs229 InspectorTest.log("");230 InspectorTest.log("-- Known issues <https://webkit.org/b/165155>");231 232 244 testInvalid("http://"); 233 testInvalid("http://example.com: 999999999");245 testInvalid("http://example.com:65537"); 234 246 235 247 testValid("http:example.com/", { … … 269 281 }); 270 282 271 testValid("http://user@pass:example.com/", { 272 scheme: "http", 273 userinfo: null, 274 host: "example.com", 275 port: null, 276 origin: "http://example.com", 277 path: "/", 278 queryString: null, 279 fragment: null, 280 lastPathComponent: null, 281 }); 283 testValid("http://:pass@example.com/", { 284 scheme: "http", 285 userinfo: ":pass", 286 host: "example.com", 287 port: null, 288 origin: "http://example.com", 289 path: "/", 290 queryString: null, 291 fragment: null, 292 lastPathComponent: null, 293 }); 294 295 testInvalid("http://user@pass:example.com/"); 282 296 283 297 testValid("http://example.com?key=alpha/beta", { … … 287 301 port: null, 288 302 origin: "http://example.com", 289 path: null,303 path: "/", 290 304 queryString: "key=alpha/beta", 291 305 fragment: null, … … 444 458 test() { 445 459 function test(tests) { 446 for (let {url, expected} of tests) 460 for (let {url, expected} of tests) { 461 expected = expected || url; 447 462 InspectorTest.expectEqual(WI.displayNameForURL(url), expected, `Display name of '${url}' should be '${expected}'.`); 463 } 448 464 449 465 InspectorTest.newline(); 450 466 451 467 InspectorTest.log("Allowing directory as name..."); 452 for (let {url, expected, directory} of tests) 453 InspectorTest.expectEqual(WI.displayNameForURL(url, null, {allowDirectoryAsName: true}), directory || expected, `Display name of '${url}' should be '${directory || expected}'.`); 468 for (let {url, expected, directory} of tests) { 469 expected = directory || expected || url; 470 InspectorTest.expectEqual(WI.displayNameForURL(url, null, {allowDirectoryAsName: true}), expected, `Display name of '${url}' should be '${expected}'.`); 471 } 454 472 } 455 473 456 474 test([ 457 {url: "a", expected: "a"}, 458 459 {url: "http://", expected: "http://"}, 460 {url: "http://example", expected: "example"}, 461 {url: "http://example.com", expected: "example.com"}, 475 {url: "http://example", expected: "example", directory: "/"}, 476 {url: "http://example.com", expected: "example.com", directory: "/"}, 462 477 {url: "http://example.com/", expected: "example.com", directory: "/"}, 463 {url: "http://example.com:999999999", expected: "example.com"},464 478 {url: "http://example.com:80/", expected: "example.com", directory: "/"}, 479 {url: "http://example.com:42/", expected: "example.com", directory: "/"}, 465 480 {url: "http://example.com/path", expected: "path"}, 466 481 {url: "http://example.com/path/", expected: "path", directory: "/"}, … … 475 490 {url: "http://example.com:123/path/to/page.html?a=1&b=foo%2Fbar#test", expected: "page.html"}, 476 491 477 {url: "http://example.com#foo%20bar", expected: "example.com" },492 {url: "http://example.com#foo%20bar", expected: "example.com", directory: "/"}, 478 493 {url: "http://example.com/#foo%20bar", expected: "example.com", directory: "/"}, 479 494 {url: "http://example.com/foo%20bar", expected: "foo bar"}, 495 {url: "http://example.com?key=foo%20bar", expected: "example.com", directory: "/"}, 480 496 {url: "http://example.com/?key=foo%20bar", expected: "example.com", directory: "/"}, 497 {url: "http://example.com?key=foo bar", expected: "example.com", directory: "/"}, 498 {url: "http://example.com/?key=foo bar", expected: "example.com", directory: "/"}, 481 499 {url: "http://example.com/foo%20bar", expected: "foo bar"}, 482 500 {url: "http://example.com/foo bar", expected: "foo bar"}, 483 501 484 {url: "http://example.com#foo/bar", expected: "example.com" },502 {url: "http://example.com#foo/bar", expected: "example.com", directory: "/"}, 485 503 {url: "http://example.com/#foo/bar", expected: "example.com", directory: "/"}, 486 {url: "http://example.com#foo%2Fbar", expected: "example.com" },504 {url: "http://example.com#foo%2Fbar", expected: "example.com", directory: "/"}, 487 505 {url: "http://example.com/#foo%2Fbar", expected: "example.com", directory: "/"}, 506 {url: "http://example.com?key=foo%2Fbar", expected: "example.com", directory: "/"}, 488 507 {url: "http://example.com/?key=foo%2Fbar", expected: "example.com", directory: "/"}, 508 {url: "http://example.com?key=foo/bar", expected: "example.com", directory: "/"}, 509 {url: "http://example.com/?key=foo/bar", expected: "example.com", directory: "/"}, 489 510 {url: "http://example.com/foo%2Fbar", expected: "foo/bar"}, 490 511 491 512 {url: "http://user:pass@example.com/", expected: "example.com", directory: "/"}, 492 493 {url: "http://my.example.com", expected: "my.example.com"}, 513 {url: "http://:pass@example.com/", expected: "example.com", directory: "/"}, 514 515 {url: "http://my.example.com", expected: "my.example.com", directory: "/"}, 494 516 {url: "http://my.example.com/", expected: "my.example.com", directory: "/"}, 495 517 … … 506 528 {url: "app-specific://example.com/", expected: "example.com", directory: "/"}, 507 529 {url: "app-specific://example.com/path", expected: "path"}, 508 ]); 509 510 // FIXME: <https://webkit.org/b/165155> Web Inspector: Use URL constructor to better handle all kinds of URLs 511 InspectorTest.newline(); 512 InspectorTest.log("-- Known issues <https://webkit.org/b/165155>"); 513 InspectorTest.newline(); 514 515 test([ 516 {url: "http://example.com?key=foo%2Fbar", expected: "example.com"}, 517 {url: "http://example.com?key=foo/bar", expected: "example.com"}, 518 519 {url: "http://example.com?key=foo%20bar", expected: "example.com"}, 520 {url: "http://example.com?key=foo bar", expected: "example.com"}, 530 531 // Invalid 532 {url: "a"}, 533 {url: "http://"}, 534 {url: "http://example.com:65537"}, 535 {url: "http://user@pass:example.com/"}, 521 536 ]); 522 537 }, … … 551 566 test("https://user:pass@example.com:123/foo", "example.com:123"); 552 567 568 test("ftp://:pass@example.com/foo", ":pass@example.com"); 569 test("http://:pass@example.com/foo", "example.com"); 570 test("https://:pass@example.com/foo", "example.com"); 571 572 test("ftp://:pass@example.com:123/foo", ":pass@example.com:123"); 573 test("http://:pass@example.com:123/foo", "example.com:123"); 574 test("https://:pass@example.com:123/foo", "example.com:123"); 575 553 576 return true; 554 577 } … … 565 588 test("http://example.com", "/"); 566 589 test("https://example.com", "/"); 567 test("ftp://example.com", " ");590 test("ftp://example.com", "/"); 568 591 569 592 test("http://example.com/foo", "/foo"); -
trunk/Source/WebInspectorUI/ChangeLog
r248894 r248895 1 2019-08-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Use URL constructor to better handle all kinds of URLs 4 https://bugs.webkit.org/show_bug.cgi?id=165155 5 6 Reviewed by Joseph Pecoraro. 7 8 * UserInterface/Base/URLUtilities.js: 9 (parseURL): 10 1 11 2019-08-19 Devin Rousso <drousso@apple.com> 2 12 -
trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js
r248753 r248895 24 24 */ 25 25 26 // FIXME: <https://webkit.org/b/165155> Web Inspector: Use URL constructor to better handle all kinds of URLs27 28 26 function removeURLFragment(url) 29 27 { … … 94 92 function parseURL(url) 95 93 { 96 url = url ? url.trim() : ""; 97 98 if (url.startsWith("data:")) 99 return {scheme: "data", userinfo: null, host: null, port: null, origin: null, path: null, queryString: null, fragment: null, lastPathComponent: null}; 100 101 let match = url.match(/^(?<scheme>[^\/:]+):\/\/(?:(?<userinfo>[^#@\/]+)@)?(?<host>[^\/#:]*)(?::(?<port>[\d]+))?(?:(?<path>\/[^#]*)?(?:#(?<fragment>.*))?)?$/i); 102 if (!match) 103 return {scheme: null, userinfo: null, host: null, port: null, origin: null, path: null, queryString: null, fragment: null, lastPathComponent: null}; 104 105 let scheme = match.groups.scheme.toLowerCase(); 106 let userinfo = match.groups.userinfo || null; 107 let host = match.groups.host.toLowerCase(); 108 let port = Number(match.groups.port) || null; 109 let wholePath = match.groups.path || null; 110 let fragment = match.groups.fragment || null; 111 let path = wholePath; 112 let queryString = null; 113 114 // Split the path and the query string. 115 if (wholePath) { 116 let indexOfQuery = wholePath.indexOf("?"); 117 if (indexOfQuery !== -1) { 118 path = wholePath.substring(0, indexOfQuery); 119 queryString = wholePath.substring(indexOfQuery + 1); 120 } 121 path = resolveDotsInPath(path); 122 } 94 let result = { 95 scheme: null, 96 userinfo: null, 97 host: null, 98 port: null, 99 origin: null, 100 path: null, 101 queryString: null, 102 fragment: null, 103 lastPathComponent: null, 104 }; 105 106 // dataURLs should be handled by `parseDataURL`. 107 if (url && url.startsWith("data:")) { 108 result.scheme = "data"; 109 return result; 110 } 111 112 let parsed = null; 113 try { 114 parsed = new URL(url); 115 } catch { 116 return result; 117 } 118 119 result.scheme = parsed.protocol.slice(0, -1); // remove trailing ":" 120 121 if (parsed.username) 122 result.userinfo = parsed.username; 123 if (parsed.password) 124 result.userinfo = (result.userinfo || "") + ":" + parsed.password; 125 126 if (parsed.hostname) 127 result.host = parsed.hostname; 128 129 if (parsed.port) 130 result.port = Number(parsed.port); 131 132 if (parsed.origin) 133 result.origin = parsed.origin; 134 else if (result.scheme && result.host) { 135 result.origin = result.scheme + "://" + result.host; 136 if (result.port) 137 result.origin += ":" + result.port; 138 } 139 140 if (parsed.pathname) 141 result.path = parsed.pathname; 142 143 if (parsed.search) 144 result.queryString = parsed.search.substring(1); // remove leading "?" 145 146 if (parsed.hash) 147 result.fragment = parsed.hash.substring(1); // remove leading "#" 123 148 124 149 // Find last path component. 125 let lastPathComponent = null; 126 if (path && path !== "/") { 150 if (result.path && result.path !== "/") { 127 151 // Skip the trailing slash if there is one. 128 let endOffset = path[path.length - 1] === "/"? 1 : 0;129 let lastSlashIndex = path.lastIndexOf("/",path.length - 1 - endOffset);152 let endOffset = result.path.endsWith("/") ? 1 : 0; 153 let lastSlashIndex = result.path.lastIndexOf("/", result.path.length - 1 - endOffset); 130 154 if (lastSlashIndex !== -1) 131 lastPathComponent = path.substring(lastSlashIndex + 1, path.length - endOffset); 132 } 133 134 let origin = null; 135 if (scheme && host) { 136 origin = scheme + "://" + host; 137 if (port) 138 origin += ":" + port; 139 } 140 141 return {scheme, userinfo, host, port, origin, path, queryString, fragment, lastPathComponent}; 155 result.lastPathComponent = result.path.substring(lastSlashIndex + 1, result.path.length - endOffset); 156 } 157 158 return result; 142 159 } 143 160
Note: See TracChangeset
for help on using the changeset viewer.