| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/******/ var __webpack_modules__ = ({ |
| 3 |
|
| 4 |
/***/ 4793: |
| 5 |
/***/ ((module) => { |
| 6 |
|
| 7 |
var characterMap = { |
| 8 |
"À": "A", |
| 9 |
"Á": "A", |
| 10 |
"Â": "A", |
| 11 |
"Ã": "A", |
| 12 |
"Ä": "A", |
| 13 |
"� |
| 14 |
": "A", |
| 15 |
"Ấ": "A", |
| 16 |
"Ắ": "A", |
| 17 |
"Ẳ": "A", |
| 18 |
"Ẵ": "A", |
| 19 |
"Ặ": "A", |
| 20 |
"Æ": "AE", |
| 21 |
"Ầ": "A", |
| 22 |
"Ằ": "A", |
| 23 |
"Ȃ": "A", |
| 24 |
"Ả": "A", |
| 25 |
"Ạ": "A", |
| 26 |
"Ẩ": "A", |
| 27 |
"Ẫ": "A", |
| 28 |
"Ậ": "A", |
| 29 |
"Ç": "C", |
| 30 |
"Ḉ": "C", |
| 31 |
"È": "E", |
| 32 |
"É": "E", |
| 33 |
"Ê": "E", |
| 34 |
"Ë": "E", |
| 35 |
"Ế": "E", |
| 36 |
"Ḗ": "E", |
| 37 |
"Ề": "E", |
| 38 |
"Ḕ": "E", |
| 39 |
"Ḝ": "E", |
| 40 |
"Ȇ": "E", |
| 41 |
"Ẻ": "E", |
| 42 |
"Ẽ": "E", |
| 43 |
"Ẹ": "E", |
| 44 |
"Ể": "E", |
| 45 |
"Ễ": "E", |
| 46 |
"Ệ": "E", |
| 47 |
"Ì": "I", |
| 48 |
"Í": "I", |
| 49 |
"Î": "I", |
| 50 |
"Ï": "I", |
| 51 |
"Ḯ": "I", |
| 52 |
"Ȋ": "I", |
| 53 |
"Ỉ": "I", |
| 54 |
"Ị": "I", |
| 55 |
"Ð": "D", |
| 56 |
"Ñ": "N", |
| 57 |
"Ò": "O", |
| 58 |
"Ó": "O", |
| 59 |
"Ô": "O", |
| 60 |
"Õ": "O", |
| 61 |
"Ö": "O", |
| 62 |
"Ø": "O", |
| 63 |
"Ố": "O", |
| 64 |
"Ṍ": "O", |
| 65 |
"Ṓ": "O", |
| 66 |
"Ȏ": "O", |
| 67 |
"Ỏ": "O", |
| 68 |
"Ọ": "O", |
| 69 |
"Ổ": "O", |
| 70 |
"Ỗ": "O", |
| 71 |
"Ộ": "O", |
| 72 |
"Ờ": "O", |
| 73 |
"Ở": "O", |
| 74 |
"Ỡ": "O", |
| 75 |
"Ớ": "O", |
| 76 |
"Ợ": "O", |
| 77 |
"Ù": "U", |
| 78 |
"Ú": "U", |
| 79 |
"Û": "U", |
| 80 |
"Ü": "U", |
| 81 |
"Ủ": "U", |
| 82 |
"Ụ": "U", |
| 83 |
"Ử": "U", |
| 84 |
"Ữ": "U", |
| 85 |
"Ự": "U", |
| 86 |
"Ý": "Y", |
| 87 |
"à": "a", |
| 88 |
"á": "a", |
| 89 |
"â": "a", |
| 90 |
"ã": "a", |
| 91 |
"ä": "a", |
| 92 |
"å": "a", |
| 93 |
"ấ": "a", |
| 94 |
"ắ": "a", |
| 95 |
"ẳ": "a", |
| 96 |
"ẵ": "a", |
| 97 |
"ặ": "a", |
| 98 |
"æ": "ae", |
| 99 |
"ầ": "a", |
| 100 |
"ằ": "a", |
| 101 |
"ȃ": "a", |
| 102 |
"ả": "a", |
| 103 |
"ạ": "a", |
| 104 |
"ẩ": "a", |
| 105 |
"ẫ": "a", |
| 106 |
"ậ": "a", |
| 107 |
"ç": "c", |
| 108 |
"ḉ": "c", |
| 109 |
"è": "e", |
| 110 |
"é": "e", |
| 111 |
"ê": "e", |
| 112 |
"ë": "e", |
| 113 |
"ế": "e", |
| 114 |
"ḗ": "e", |
| 115 |
"ề": "e", |
| 116 |
"ḕ": "e", |
| 117 |
"ḝ": "e", |
| 118 |
"ȇ": "e", |
| 119 |
"ẻ": "e", |
| 120 |
"ẽ": "e", |
| 121 |
"ẹ": "e", |
| 122 |
"ể": "e", |
| 123 |
"� |
| 124 |
": "e", |
| 125 |
"ệ": "e", |
| 126 |
"ì": "i", |
| 127 |
"í": "i", |
| 128 |
"î": "i", |
| 129 |
"ï": "i", |
| 130 |
"ḯ": "i", |
| 131 |
"ȋ": "i", |
| 132 |
"ỉ": "i", |
| 133 |
"ị": "i", |
| 134 |
"ð": "d", |
| 135 |
"ñ": "n", |
| 136 |
"ò": "o", |
| 137 |
"ó": "o", |
| 138 |
"ô": "o", |
| 139 |
"õ": "o", |
| 140 |
"ö": "o", |
| 141 |
"ø": "o", |
| 142 |
"ố": "o", |
| 143 |
"ṍ": "o", |
| 144 |
"ṓ": "o", |
| 145 |
"ȏ": "o", |
| 146 |
"ỏ": "o", |
| 147 |
"ọ": "o", |
| 148 |
"ổ": "o", |
| 149 |
"ỗ": "o", |
| 150 |
"ộ": "o", |
| 151 |
"ờ": "o", |
| 152 |
"ở": "o", |
| 153 |
"ỡ": "o", |
| 154 |
"ớ": "o", |
| 155 |
"ợ": "o", |
| 156 |
"ù": "u", |
| 157 |
"ú": "u", |
| 158 |
"û": "u", |
| 159 |
"ü": "u", |
| 160 |
"ủ": "u", |
| 161 |
"ụ": "u", |
| 162 |
"ử": "u", |
| 163 |
"ữ": "u", |
| 164 |
"ự": "u", |
| 165 |
"ý": "y", |
| 166 |
"ÿ": "y", |
| 167 |
"Ā": "A", |
| 168 |
"ā": "a", |
| 169 |
"Ă": "A", |
| 170 |
"ă": "a", |
| 171 |
"Ą": "A", |
| 172 |
"� |
| 173 |
": "a", |
| 174 |
"Ć": "C", |
| 175 |
"ć": "c", |
| 176 |
"Ĉ": "C", |
| 177 |
"ĉ": "c", |
| 178 |
"Ċ": "C", |
| 179 |
"ċ": "c", |
| 180 |
"Č": "C", |
| 181 |
"č": "c", |
| 182 |
"C̆": "C", |
| 183 |
"c̆": "c", |
| 184 |
"Ď": "D", |
| 185 |
"ď": "d", |
| 186 |
"Đ": "D", |
| 187 |
"đ": "d", |
| 188 |
"Ē": "E", |
| 189 |
"ē": "e", |
| 190 |
"Ĕ": "E", |
| 191 |
"ĕ": "e", |
| 192 |
"Ė": "E", |
| 193 |
"ė": "e", |
| 194 |
"Ę": "E", |
| 195 |
"ę": "e", |
| 196 |
"Ě": "E", |
| 197 |
"ě": "e", |
| 198 |
"Ĝ": "G", |
| 199 |
"Ǵ": "G", |
| 200 |
"ĝ": "g", |
| 201 |
"ǵ": "g", |
| 202 |
"Ğ": "G", |
| 203 |
"ğ": "g", |
| 204 |
"Ġ": "G", |
| 205 |
"ġ": "g", |
| 206 |
"Ģ": "G", |
| 207 |
"ģ": "g", |
| 208 |
"Ĥ": "H", |
| 209 |
"ĥ": "h", |
| 210 |
"Ħ": "H", |
| 211 |
"ħ": "h", |
| 212 |
"Ḫ": "H", |
| 213 |
"ḫ": "h", |
| 214 |
"Ĩ": "I", |
| 215 |
"ĩ": "i", |
| 216 |
"Ī": "I", |
| 217 |
"ī": "i", |
| 218 |
"Ĭ": "I", |
| 219 |
"ĭ": "i", |
| 220 |
"Į": "I", |
| 221 |
"į": "i", |
| 222 |
"İ": "I", |
| 223 |
"ı": "i", |
| 224 |
"IJ": "IJ", |
| 225 |
"ij": "ij", |
| 226 |
"Ĵ": "J", |
| 227 |
"ĵ": "j", |
| 228 |
"Ķ": "K", |
| 229 |
"ķ": "k", |
| 230 |
"Ḱ": "K", |
| 231 |
"ḱ": "k", |
| 232 |
"K̆": "K", |
| 233 |
"k̆": "k", |
| 234 |
"Ĺ": "L", |
| 235 |
"ĺ": "l", |
| 236 |
"Ļ": "L", |
| 237 |
"ļ": "l", |
| 238 |
"Ľ": "L", |
| 239 |
"ľ": "l", |
| 240 |
"Ŀ": "L", |
| 241 |
"ŀ": "l", |
| 242 |
"Ł": "l", |
| 243 |
"ł": "l", |
| 244 |
"Ḿ": "M", |
| 245 |
"ḿ": "m", |
| 246 |
"M̆": "M", |
| 247 |
"m̆": "m", |
| 248 |
"Ń": "N", |
| 249 |
"ń": "n", |
| 250 |
"� |
| 251 |
": "N", |
| 252 |
"ņ": "n", |
| 253 |
"Ň": "N", |
| 254 |
"ň": "n", |
| 255 |
"ʼn": "n", |
| 256 |
"N̆": "N", |
| 257 |
"n̆": "n", |
| 258 |
"Ō": "O", |
| 259 |
"ō": "o", |
| 260 |
"Ŏ": "O", |
| 261 |
"ŏ": "o", |
| 262 |
"Ő": "O", |
| 263 |
"ő": "o", |
| 264 |
"Œ": "OE", |
| 265 |
"œ": "oe", |
| 266 |
"P̆": "P", |
| 267 |
"p̆": "p", |
| 268 |
"Ŕ": "R", |
| 269 |
"ŕ": "r", |
| 270 |
"Ŗ": "R", |
| 271 |
"ŗ": "r", |
| 272 |
"Ř": "R", |
| 273 |
"ř": "r", |
| 274 |
"R̆": "R", |
| 275 |
"r̆": "r", |
| 276 |
"Ȓ": "R", |
| 277 |
"ȓ": "r", |
| 278 |
"Ś": "S", |
| 279 |
"ś": "s", |
| 280 |
"Ŝ": "S", |
| 281 |
"ŝ": "s", |
| 282 |
"Ş": "S", |
| 283 |
"Ș": "S", |
| 284 |
"ș": "s", |
| 285 |
"ş": "s", |
| 286 |
"Š": "S", |
| 287 |
"š": "s", |
| 288 |
"Ţ": "T", |
| 289 |
"ţ": "t", |
| 290 |
"ț": "t", |
| 291 |
"Ț": "T", |
| 292 |
"Ť": "T", |
| 293 |
"ť": "t", |
| 294 |
"Ŧ": "T", |
| 295 |
"ŧ": "t", |
| 296 |
"T̆": "T", |
| 297 |
"t̆": "t", |
| 298 |
"Ũ": "U", |
| 299 |
"ũ": "u", |
| 300 |
"Ū": "U", |
| 301 |
"ū": "u", |
| 302 |
"Ŭ": "U", |
| 303 |
"ŭ": "u", |
| 304 |
"Ů": "U", |
| 305 |
"ů": "u", |
| 306 |
"Ű": "U", |
| 307 |
"ű": "u", |
| 308 |
"Ų": "U", |
| 309 |
"ų": "u", |
| 310 |
"Ȗ": "U", |
| 311 |
"ȗ": "u", |
| 312 |
"V̆": "V", |
| 313 |
"v̆": "v", |
| 314 |
"Ŵ": "W", |
| 315 |
"ŵ": "w", |
| 316 |
"Ẃ": "W", |
| 317 |
"ẃ": "w", |
| 318 |
"X̆": "X", |
| 319 |
"x̆": "x", |
| 320 |
"Ŷ": "Y", |
| 321 |
"ŷ": "y", |
| 322 |
"Ÿ": "Y", |
| 323 |
"Y̆": "Y", |
| 324 |
"y̆": "y", |
| 325 |
"Ź": "Z", |
| 326 |
"ź": "z", |
| 327 |
"Ż": "Z", |
| 328 |
"ż": "z", |
| 329 |
"Ž": "Z", |
| 330 |
"ž": "z", |
| 331 |
"ſ": "s", |
| 332 |
"ƒ": "f", |
| 333 |
"Ơ": "O", |
| 334 |
"ơ": "o", |
| 335 |
"Ư": "U", |
| 336 |
"ư": "u", |
| 337 |
"Ǎ": "A", |
| 338 |
"ǎ": "a", |
| 339 |
"Ǐ": "I", |
| 340 |
"ǐ": "i", |
| 341 |
"Ǒ": "O", |
| 342 |
"ǒ": "o", |
| 343 |
"Ǔ": "U", |
| 344 |
"ǔ": "u", |
| 345 |
"Ǖ": "U", |
| 346 |
"ǖ": "u", |
| 347 |
"Ǘ": "U", |
| 348 |
"ǘ": "u", |
| 349 |
"Ǚ": "U", |
| 350 |
"ǚ": "u", |
| 351 |
"Ǜ": "U", |
| 352 |
"ǜ": "u", |
| 353 |
"Ứ": "U", |
| 354 |
"ứ": "u", |
| 355 |
"Ṹ": "U", |
| 356 |
"ṹ": "u", |
| 357 |
"Ǻ": "A", |
| 358 |
"ǻ": "a", |
| 359 |
"Ǽ": "AE", |
| 360 |
"ǽ": "ae", |
| 361 |
"Ǿ": "O", |
| 362 |
"ǿ": "o", |
| 363 |
"Þ": "TH", |
| 364 |
"þ": "th", |
| 365 |
"Ṕ": "P", |
| 366 |
"ṕ": "p", |
| 367 |
"Ṥ": "S", |
| 368 |
"ṥ": "s", |
| 369 |
"X́": "X", |
| 370 |
"x́": "x", |
| 371 |
"Ѓ": "Г", |
| 372 |
"ѓ": "г", |
| 373 |
"Ќ": "К", |
| 374 |
"ќ": "к", |
| 375 |
"A̋": "A", |
| 376 |
"a̋": "a", |
| 377 |
"E̋": "E", |
| 378 |
"e̋": "e", |
| 379 |
"I̋": "I", |
| 380 |
"i̋": "i", |
| 381 |
"Ǹ": "N", |
| 382 |
"ǹ": "n", |
| 383 |
"Ồ": "O", |
| 384 |
"ồ": "o", |
| 385 |
"Ṑ": "O", |
| 386 |
"ṑ": "o", |
| 387 |
"Ừ": "U", |
| 388 |
"ừ": "u", |
| 389 |
"Ẁ": "W", |
| 390 |
"ẁ": "w", |
| 391 |
"Ỳ": "Y", |
| 392 |
"ỳ": "y", |
| 393 |
"Ȁ": "A", |
| 394 |
"ȁ": "a", |
| 395 |
"Ȅ": "E", |
| 396 |
"� |
| 397 |
": "e", |
| 398 |
"Ȉ": "I", |
| 399 |
"ȉ": "i", |
| 400 |
"Ȍ": "O", |
| 401 |
"ȍ": "o", |
| 402 |
"Ȑ": "R", |
| 403 |
"ȑ": "r", |
| 404 |
"Ȕ": "U", |
| 405 |
"ȕ": "u", |
| 406 |
"B̌": "B", |
| 407 |
"b̌": "b", |
| 408 |
"Č̣": "C", |
| 409 |
"č̣": "c", |
| 410 |
"Ê̌": "E", |
| 411 |
"ê̌": "e", |
| 412 |
"F̌": "F", |
| 413 |
"f̌": "f", |
| 414 |
"Ǧ": "G", |
| 415 |
"ǧ": "g", |
| 416 |
"Ȟ": "H", |
| 417 |
"ȟ": "h", |
| 418 |
"J̌": "J", |
| 419 |
"ǰ": "j", |
| 420 |
"Ǩ": "K", |
| 421 |
"ǩ": "k", |
| 422 |
"M̌": "M", |
| 423 |
"m̌": "m", |
| 424 |
"P̌": "P", |
| 425 |
"p̌": "p", |
| 426 |
"Q̌": "Q", |
| 427 |
"q̌": "q", |
| 428 |
"Ř̩": "R", |
| 429 |
"ř̩": "r", |
| 430 |
"Ṧ": "S", |
| 431 |
"ṧ": "s", |
| 432 |
"V̌": "V", |
| 433 |
"v̌": "v", |
| 434 |
"W̌": "W", |
| 435 |
"w̌": "w", |
| 436 |
"X̌": "X", |
| 437 |
"x̌": "x", |
| 438 |
"Y̌": "Y", |
| 439 |
"y̌": "y", |
| 440 |
"A̧": "A", |
| 441 |
"a̧": "a", |
| 442 |
"B̧": "B", |
| 443 |
"b̧": "b", |
| 444 |
"Ḑ": "D", |
| 445 |
"ḑ": "d", |
| 446 |
"Ȩ": "E", |
| 447 |
"ȩ": "e", |
| 448 |
"Ɛ̧": "E", |
| 449 |
"ɛ̧": "e", |
| 450 |
"Ḩ": "H", |
| 451 |
"ḩ": "h", |
| 452 |
"I̧": "I", |
| 453 |
"i̧": "i", |
| 454 |
"Ɨ̧": "I", |
| 455 |
"ɨ̧": "i", |
| 456 |
"M̧": "M", |
| 457 |
"m̧": "m", |
| 458 |
"O̧": "O", |
| 459 |
"o̧": "o", |
| 460 |
"Q̧": "Q", |
| 461 |
"q̧": "q", |
| 462 |
"U̧": "U", |
| 463 |
"u̧": "u", |
| 464 |
"X̧": "X", |
| 465 |
"x̧": "x", |
| 466 |
"Z̧": "Z", |
| 467 |
"z̧": "z", |
| 468 |
"й":"и", |
| 469 |
"Й":"И", |
| 470 |
"ё":"е", |
| 471 |
"Ё":"Е", |
| 472 |
}; |
| 473 |
|
| 474 |
var chars = Object.keys(characterMap).join('|'); |
| 475 |
var allAccents = new RegExp(chars, 'g'); |
| 476 |
var firstAccent = new RegExp(chars, ''); |
| 477 |
|
| 478 |
function matcher(match) { |
| 479 |
return characterMap[match]; |
| 480 |
} |
| 481 |
|
| 482 |
var removeAccents = function(string) { |
| 483 |
return string.replace(allAccents, matcher); |
| 484 |
}; |
| 485 |
|
| 486 |
var hasAccents = function(string) { |
| 487 |
return !!string.match(firstAccent); |
| 488 |
}; |
| 489 |
|
| 490 |
module.exports = removeAccents; |
| 491 |
module.exports.has = hasAccents; |
| 492 |
module.exports.remove = removeAccents; |
| 493 |
|
| 494 |
|
| 495 |
/***/ }) |
| 496 |
|
| 497 |
/******/ }); |
| 498 |
/************************************************************************/ |
| 499 |
/******/ // The module cache |
| 500 |
/******/ var __webpack_module_cache__ = {}; |
| 501 |
/******/ |
| 502 |
/******/ // The require function |
| 503 |
/******/ function __webpack_require__(moduleId) { |
| 504 |
/******/ // Check if module is in cache |
| 505 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 506 |
/******/ if (cachedModule !== undefined) { |
| 507 |
/******/ return cachedModule.exports; |
| 508 |
/******/ } |
| 509 |
/******/ // Create a new module (and put it into the cache) |
| 510 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 511 |
/******/ // no module.id needed |
| 512 |
/******/ // no module.loaded needed |
| 513 |
/******/ exports: {} |
| 514 |
/******/ }; |
| 515 |
/******/ |
| 516 |
/******/ // Execute the module function |
| 517 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 518 |
/******/ |
| 519 |
/******/ // Return the exports of the module |
| 520 |
/******/ return module.exports; |
| 521 |
/******/ } |
| 522 |
/******/ |
| 523 |
/************************************************************************/ |
| 524 |
/******/ /* webpack/runtime/compat get default export */ |
| 525 |
/******/ (() => { |
| 526 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 527 |
/******/ __webpack_require__.n = (module) => { |
| 528 |
/******/ var getter = module && module.__esModule ? |
| 529 |
/******/ () => (module['default']) : |
| 530 |
/******/ () => (module); |
| 531 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 532 |
/******/ return getter; |
| 533 |
/******/ }; |
| 534 |
/******/ })(); |
| 535 |
/******/ |
| 536 |
/******/ /* webpack/runtime/define property getters */ |
| 537 |
/******/ (() => { |
| 538 |
/******/ // define getter functions for harmony exports |
| 539 |
/******/ __webpack_require__.d = (exports, definition) => { |
| 540 |
/******/ for(var key in definition) { |
| 541 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 542 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 543 |
/******/ } |
| 544 |
/******/ } |
| 545 |
/******/ }; |
| 546 |
/******/ })(); |
| 547 |
/******/ |
| 548 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 549 |
/******/ (() => { |
| 550 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 551 |
/******/ })(); |
| 552 |
/******/ |
| 553 |
/******/ /* webpack/runtime/make namespace object */ |
| 554 |
/******/ (() => { |
| 555 |
/******/ // define __esModule on exports |
| 556 |
/******/ __webpack_require__.r = (exports) => { |
| 557 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 558 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 559 |
/******/ } |
| 560 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 561 |
/******/ }; |
| 562 |
/******/ })(); |
| 563 |
/******/ |
| 564 |
/************************************************************************/ |
| 565 |
var __webpack_exports__ = {}; |
| 566 |
// This entry need to be wrapped in an IIFE because it need to be in strict mode. |
| 567 |
(() => { |
| 568 |
"use strict"; |
| 569 |
// ESM COMPAT FLAG |
| 570 |
__webpack_require__.r(__webpack_exports__); |
| 571 |
|
| 572 |
// EXPORTS |
| 573 |
__webpack_require__.d(__webpack_exports__, { |
| 574 |
"addQueryArgs": () => (/* reexport */ addQueryArgs), |
| 575 |
"buildQueryString": () => (/* reexport */ buildQueryString), |
| 576 |
"cleanForSlug": () => (/* reexport */ cleanForSlug), |
| 577 |
"filterURLForDisplay": () => (/* reexport */ filterURLForDisplay), |
| 578 |
"getAuthority": () => (/* reexport */ getAuthority), |
| 579 |
"getFilename": () => (/* reexport */ getFilename), |
| 580 |
"getFragment": () => (/* reexport */ getFragment), |
| 581 |
"getPath": () => (/* reexport */ getPath), |
| 582 |
"getPathAndQueryString": () => (/* reexport */ getPathAndQueryString), |
| 583 |
"getProtocol": () => (/* reexport */ getProtocol), |
| 584 |
"getQueryArg": () => (/* reexport */ getQueryArg), |
| 585 |
"getQueryArgs": () => (/* reexport */ getQueryArgs), |
| 586 |
"getQueryString": () => (/* reexport */ getQueryString), |
| 587 |
"hasQueryArg": () => (/* reexport */ hasQueryArg), |
| 588 |
"isEmail": () => (/* reexport */ isEmail), |
| 589 |
"isURL": () => (/* reexport */ isURL), |
| 590 |
"isValidAuthority": () => (/* reexport */ isValidAuthority), |
| 591 |
"isValidFragment": () => (/* reexport */ isValidFragment), |
| 592 |
"isValidPath": () => (/* reexport */ isValidPath), |
| 593 |
"isValidProtocol": () => (/* reexport */ isValidProtocol), |
| 594 |
"isValidQueryString": () => (/* reexport */ isValidQueryString), |
| 595 |
"normalizePath": () => (/* reexport */ normalizePath), |
| 596 |
"prependHTTP": () => (/* reexport */ prependHTTP), |
| 597 |
"prependHTTPS": () => (/* reexport */ prependHTTPS), |
| 598 |
"removeQueryArgs": () => (/* reexport */ removeQueryArgs), |
| 599 |
"safeDecodeURI": () => (/* reexport */ safeDecodeURI), |
| 600 |
"safeDecodeURIComponent": () => (/* reexport */ safeDecodeURIComponent) |
| 601 |
}); |
| 602 |
|
| 603 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-url.js |
| 604 |
/** |
| 605 |
* Determines whether the given string looks like a URL. |
| 606 |
* |
| 607 |
* @param {string} url The string to scrutinise. |
| 608 |
* |
| 609 |
* @example |
| 610 |
* ```js |
| 611 |
* const isURL = isURL( 'https://wordpress.org' ); // true |
| 612 |
* ``` |
| 613 |
* |
| 614 |
* @see https://url.spec.whatwg.org/ |
| 615 |
* @see https://url.spec.whatwg.org/#valid-url-string |
| 616 |
* |
| 617 |
* @return {boolean} Whether or not it looks like a URL. |
| 618 |
*/ |
| 619 |
function isURL(url) { |
| 620 |
// A URL can be considered value if the `URL` constructor is able to parse |
| 621 |
// it. The constructor throws an error for an invalid URL. |
| 622 |
try { |
| 623 |
new URL(url); |
| 624 |
return true; |
| 625 |
} catch { |
| 626 |
return false; |
| 627 |
} |
| 628 |
} |
| 629 |
|
| 630 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-email.js |
| 631 |
const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; |
| 632 |
|
| 633 |
/** |
| 634 |
* Determines whether the given string looks like an email. |
| 635 |
* |
| 636 |
* @param {string} email The string to scrutinise. |
| 637 |
* |
| 638 |
* @example |
| 639 |
* ```js |
| 640 |
* const isEmail = isEmail( 'hello@wordpress.org' ); // true |
| 641 |
* ``` |
| 642 |
* |
| 643 |
* @return {boolean} Whether or not it looks like an email. |
| 644 |
*/ |
| 645 |
function isEmail(email) { |
| 646 |
return EMAIL_REGEXP.test(email); |
| 647 |
} |
| 648 |
|
| 649 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-protocol.js |
| 650 |
/** |
| 651 |
* Returns the protocol part of the URL. |
| 652 |
* |
| 653 |
* @param {string} url The full URL. |
| 654 |
* |
| 655 |
* @example |
| 656 |
* ```js |
| 657 |
* const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' |
| 658 |
* const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' |
| 659 |
* ``` |
| 660 |
* |
| 661 |
* @return {string|void} The protocol part of the URL. |
| 662 |
*/ |
| 663 |
function getProtocol(url) { |
| 664 |
const matches = /^([^\s:]+:)/.exec(url); |
| 665 |
if (matches) { |
| 666 |
return matches[1]; |
| 667 |
} |
| 668 |
} |
| 669 |
|
| 670 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-protocol.js |
| 671 |
/** |
| 672 |
* Tests if a url protocol is valid. |
| 673 |
* |
| 674 |
* @param {string} protocol The url protocol. |
| 675 |
* |
| 676 |
* @example |
| 677 |
* ```js |
| 678 |
* const isValid = isValidProtocol( 'https:' ); // true |
| 679 |
* const isNotValid = isValidProtocol( 'https :' ); // false |
| 680 |
* ``` |
| 681 |
* |
| 682 |
* @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). |
| 683 |
*/ |
| 684 |
function isValidProtocol(protocol) { |
| 685 |
if (!protocol) { |
| 686 |
return false; |
| 687 |
} |
| 688 |
return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); |
| 689 |
} |
| 690 |
|
| 691 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-authority.js |
| 692 |
/** |
| 693 |
* Returns the authority part of the URL. |
| 694 |
* |
| 695 |
* @param {string} url The full URL. |
| 696 |
* |
| 697 |
* @example |
| 698 |
* ```js |
| 699 |
* const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' |
| 700 |
* const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' |
| 701 |
* ``` |
| 702 |
* |
| 703 |
* @return {string|void} The authority part of the URL. |
| 704 |
*/ |
| 705 |
function getAuthority(url) { |
| 706 |
const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); |
| 707 |
if (matches) { |
| 708 |
return matches[1]; |
| 709 |
} |
| 710 |
} |
| 711 |
|
| 712 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-authority.js |
| 713 |
/** |
| 714 |
* Checks for invalid characters within the provided authority. |
| 715 |
* |
| 716 |
* @param {string} authority A string containing the URL authority. |
| 717 |
* |
| 718 |
* @example |
| 719 |
* ```js |
| 720 |
* const isValid = isValidAuthority( 'wordpress.org' ); // true |
| 721 |
* const isNotValid = isValidAuthority( 'wordpress#org' ); // false |
| 722 |
* ``` |
| 723 |
* |
| 724 |
* @return {boolean} True if the argument contains a valid authority. |
| 725 |
*/ |
| 726 |
function isValidAuthority(authority) { |
| 727 |
if (!authority) { |
| 728 |
return false; |
| 729 |
} |
| 730 |
return /^[^\s#?]+$/.test(authority); |
| 731 |
} |
| 732 |
|
| 733 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-path.js |
| 734 |
/** |
| 735 |
* Returns the path part of the URL. |
| 736 |
* |
| 737 |
* @param {string} url The full URL. |
| 738 |
* |
| 739 |
* @example |
| 740 |
* ```js |
| 741 |
* const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' |
| 742 |
* const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' |
| 743 |
* ``` |
| 744 |
* |
| 745 |
* @return {string|void} The path part of the URL. |
| 746 |
*/ |
| 747 |
function getPath(url) { |
| 748 |
const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); |
| 749 |
if (matches) { |
| 750 |
return matches[1]; |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-path.js |
| 755 |
/** |
| 756 |
* Checks for invalid characters within the provided path. |
| 757 |
* |
| 758 |
* @param {string} path The URL path. |
| 759 |
* |
| 760 |
* @example |
| 761 |
* ```js |
| 762 |
* const isValid = isValidPath( 'test/path/' ); // true |
| 763 |
* const isNotValid = isValidPath( '/invalid?test/path/' ); // false |
| 764 |
* ``` |
| 765 |
* |
| 766 |
* @return {boolean} True if the argument contains a valid path |
| 767 |
*/ |
| 768 |
function isValidPath(path) { |
| 769 |
if (!path) { |
| 770 |
return false; |
| 771 |
} |
| 772 |
return /^[^\s#?]+$/.test(path); |
| 773 |
} |
| 774 |
|
| 775 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-query-string.js |
| 776 |
/** |
| 777 |
* Returns the query string part of the URL. |
| 778 |
* |
| 779 |
* @param {string} url The full URL. |
| 780 |
* |
| 781 |
* @example |
| 782 |
* ```js |
| 783 |
* const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' |
| 784 |
* ``` |
| 785 |
* |
| 786 |
* @return {string|void} The query string part of the URL. |
| 787 |
*/ |
| 788 |
function getQueryString(url) { |
| 789 |
let query; |
| 790 |
try { |
| 791 |
query = new URL(url, 'http://example.com').search.substring(1); |
| 792 |
} catch (error) {} |
| 793 |
if (query) { |
| 794 |
return query; |
| 795 |
} |
| 796 |
} |
| 797 |
|
| 798 |
;// CONCATENATED MODULE: ./packages/url/build-module/build-query-string.js |
| 799 |
/** |
| 800 |
* Generates URL-encoded query string using input query data. |
| 801 |
* |
| 802 |
* It is intended to behave equivalent as PHP's `http_build_query`, configured |
| 803 |
* with encoding type PHP_QUERY_RFC3986 (spaces as `%20`). |
| 804 |
* |
| 805 |
* @example |
| 806 |
* ```js |
| 807 |
* const queryString = buildQueryString( { |
| 808 |
* simple: 'is ok', |
| 809 |
* arrays: [ 'are', 'fine', 'too' ], |
| 810 |
* objects: { |
| 811 |
* evenNested: { |
| 812 |
* ok: 'yes', |
| 813 |
* }, |
| 814 |
* }, |
| 815 |
* } ); |
| 816 |
* // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes" |
| 817 |
* ``` |
| 818 |
* |
| 819 |
* @param {Record<string,*>} data Data to encode. |
| 820 |
* |
| 821 |
* @return {string} Query string. |
| 822 |
*/ |
| 823 |
function buildQueryString(data) { |
| 824 |
let string = ''; |
| 825 |
const stack = Object.entries(data); |
| 826 |
let pair; |
| 827 |
while (pair = stack.shift()) { |
| 828 |
let [key, value] = pair; |
| 829 |
|
| 830 |
// Support building deeply nested data, from array or object values. |
| 831 |
const hasNestedData = Array.isArray(value) || value && value.constructor === Object; |
| 832 |
if (hasNestedData) { |
| 833 |
// Push array or object values onto the stack as composed of their |
| 834 |
// original key and nested index or key, retaining order by a |
| 835 |
// combination of Array#reverse and Array#unshift onto the stack. |
| 836 |
const valuePairs = Object.entries(value).reverse(); |
| 837 |
for (const [member, memberValue] of valuePairs) { |
| 838 |
stack.unshift([`${key}[${member}]`, memberValue]); |
| 839 |
} |
| 840 |
} else if (value !== undefined) { |
| 841 |
// Null is treated as special case, equivalent to empty string. |
| 842 |
if (value === null) { |
| 843 |
value = ''; |
| 844 |
} |
| 845 |
string += '&' + [key, value].map(encodeURIComponent).join('='); |
| 846 |
} |
| 847 |
} |
| 848 |
|
| 849 |
// Loop will concatenate with leading `&`, but it's only expected for all |
| 850 |
// but the first query parameter. This strips the leading `&`, while still |
| 851 |
// accounting for the case that the string may in-fact be empty. |
| 852 |
return string.substr(1); |
| 853 |
} |
| 854 |
|
| 855 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-query-string.js |
| 856 |
/** |
| 857 |
* Checks for invalid characters within the provided query string. |
| 858 |
* |
| 859 |
* @param {string} queryString The query string. |
| 860 |
* |
| 861 |
* @example |
| 862 |
* ```js |
| 863 |
* const isValid = isValidQueryString( 'query=true&another=false' ); // true |
| 864 |
* const isNotValid = isValidQueryString( 'query=true?another=false' ); // false |
| 865 |
* ``` |
| 866 |
* |
| 867 |
* @return {boolean} True if the argument contains a valid query string. |
| 868 |
*/ |
| 869 |
function isValidQueryString(queryString) { |
| 870 |
if (!queryString) { |
| 871 |
return false; |
| 872 |
} |
| 873 |
return /^[^\s#?\/]+$/.test(queryString); |
| 874 |
} |
| 875 |
|
| 876 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-path-and-query-string.js |
| 877 |
/** |
| 878 |
* Internal dependencies |
| 879 |
*/ |
| 880 |
|
| 881 |
|
| 882 |
/** |
| 883 |
* Returns the path part and query string part of the URL. |
| 884 |
* |
| 885 |
* @param {string} url The full URL. |
| 886 |
* |
| 887 |
* @example |
| 888 |
* ```js |
| 889 |
* const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true' |
| 890 |
* const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq' |
| 891 |
* ``` |
| 892 |
* |
| 893 |
* @return {string} The path part and query string part of the URL. |
| 894 |
*/ |
| 895 |
function getPathAndQueryString(url) { |
| 896 |
const path = getPath(url); |
| 897 |
const queryString = getQueryString(url); |
| 898 |
let value = '/'; |
| 899 |
if (path) value += path; |
| 900 |
if (queryString) value += `?${queryString}`; |
| 901 |
return value; |
| 902 |
} |
| 903 |
|
| 904 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-fragment.js |
| 905 |
/** |
| 906 |
* Returns the fragment part of the URL. |
| 907 |
* |
| 908 |
* @param {string} url The full URL |
| 909 |
* |
| 910 |
* @example |
| 911 |
* ```js |
| 912 |
* const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' |
| 913 |
* const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' |
| 914 |
* ``` |
| 915 |
* |
| 916 |
* @return {string|void} The fragment part of the URL. |
| 917 |
*/ |
| 918 |
function getFragment(url) { |
| 919 |
const matches = /^\S+?(#[^\s\?]*)/.exec(url); |
| 920 |
if (matches) { |
| 921 |
return matches[1]; |
| 922 |
} |
| 923 |
} |
| 924 |
|
| 925 |
;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-fragment.js |
| 926 |
/** |
| 927 |
* Checks for invalid characters within the provided fragment. |
| 928 |
* |
| 929 |
* @param {string} fragment The url fragment. |
| 930 |
* |
| 931 |
* @example |
| 932 |
* ```js |
| 933 |
* const isValid = isValidFragment( '#valid-fragment' ); // true |
| 934 |
* const isNotValid = isValidFragment( '#invalid-#fragment' ); // false |
| 935 |
* ``` |
| 936 |
* |
| 937 |
* @return {boolean} True if the argument contains a valid fragment. |
| 938 |
*/ |
| 939 |
function isValidFragment(fragment) { |
| 940 |
if (!fragment) { |
| 941 |
return false; |
| 942 |
} |
| 943 |
return /^#[^\s#?\/]*$/.test(fragment); |
| 944 |
} |
| 945 |
|
| 946 |
;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri-component.js |
| 947 |
/** |
| 948 |
* Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if |
| 949 |
* `decodeURIComponent` throws an error. |
| 950 |
* |
| 951 |
* @param {string} uriComponent URI component to decode. |
| 952 |
* |
| 953 |
* @return {string} Decoded URI component if possible. |
| 954 |
*/ |
| 955 |
function safeDecodeURIComponent(uriComponent) { |
| 956 |
try { |
| 957 |
return decodeURIComponent(uriComponent); |
| 958 |
} catch (uriComponentError) { |
| 959 |
return uriComponent; |
| 960 |
} |
| 961 |
} |
| 962 |
|
| 963 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-query-args.js |
| 964 |
/** |
| 965 |
* Internal dependencies |
| 966 |
*/ |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */ |
| 971 |
|
| 972 |
/** |
| 973 |
* @typedef {Record<string,QueryArgParsed>} QueryArgs |
| 974 |
*/ |
| 975 |
|
| 976 |
/** |
| 977 |
* Sets a value in object deeply by a given array of path segments. Mutates the |
| 978 |
* object reference. |
| 979 |
* |
| 980 |
* @param {Record<string,*>} object Object in which to assign. |
| 981 |
* @param {string[]} path Path segment at which to set value. |
| 982 |
* @param {*} value Value to set. |
| 983 |
*/ |
| 984 |
function setPath(object, path, value) { |
| 985 |
const length = path.length; |
| 986 |
const lastIndex = length - 1; |
| 987 |
for (let i = 0; i < length; i++) { |
| 988 |
let key = path[i]; |
| 989 |
if (!key && Array.isArray(object)) { |
| 990 |
// If key is empty string and next value is array, derive key from |
| 991 |
// the current length of the array. |
| 992 |
key = object.length.toString(); |
| 993 |
} |
| 994 |
key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; |
| 995 |
|
| 996 |
// If the next key in the path is numeric (or empty string), it will be |
| 997 |
// created as an array. Otherwise, it will be created as an object. |
| 998 |
const isNextKeyArrayIndex = !isNaN(Number(path[i + 1])); |
| 999 |
object[key] = i === lastIndex ? |
| 1000 |
// If at end of path, assign the intended value. |
| 1001 |
value : |
| 1002 |
// Otherwise, advance to the next object in the path, creating |
| 1003 |
// it if it does not yet exist. |
| 1004 |
object[key] || (isNextKeyArrayIndex ? [] : {}); |
| 1005 |
if (Array.isArray(object[key]) && !isNextKeyArrayIndex) { |
| 1006 |
// If we current key is non-numeric, but the next value is an |
| 1007 |
// array, coerce the value to an object. |
| 1008 |
object[key] = { |
| 1009 |
...object[key] |
| 1010 |
}; |
| 1011 |
} |
| 1012 |
|
| 1013 |
// Update working reference object to the next in the path. |
| 1014 |
object = object[key]; |
| 1015 |
} |
| 1016 |
} |
| 1017 |
|
| 1018 |
/** |
| 1019 |
* Returns an object of query arguments of the given URL. If the given URL is |
| 1020 |
* invalid or has no querystring, an empty object is returned. |
| 1021 |
* |
| 1022 |
* @param {string} url URL. |
| 1023 |
* |
| 1024 |
* @example |
| 1025 |
* ```js |
| 1026 |
* const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' ); |
| 1027 |
* // { "foo": "bar", "bar": "baz" } |
| 1028 |
* ``` |
| 1029 |
* |
| 1030 |
* @return {QueryArgs} Query args object. |
| 1031 |
*/ |
| 1032 |
function getQueryArgs(url) { |
| 1033 |
return (getQueryString(url) || '' |
| 1034 |
// Normalize space encoding, accounting for PHP URL encoding |
| 1035 |
// corresponding to `application/x-www-form-urlencoded`. |
| 1036 |
// |
| 1037 |
// See: https://tools.ietf.org/html/rfc1866#section-8.2.1 |
| 1038 |
).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => { |
| 1039 |
const [key, value = ''] = keyValue.split('=') |
| 1040 |
// Filtering avoids decoding as `undefined` for value, where |
| 1041 |
// default is restored in destructuring assignment. |
| 1042 |
.filter(Boolean).map(safeDecodeURIComponent); |
| 1043 |
if (key) { |
| 1044 |
const segments = key.replace(/\]/g, '').split('['); |
| 1045 |
setPath(accumulator, segments, value); |
| 1046 |
} |
| 1047 |
return accumulator; |
| 1048 |
}, Object.create(null)); |
| 1049 |
} |
| 1050 |
|
| 1051 |
;// CONCATENATED MODULE: ./packages/url/build-module/add-query-args.js |
| 1052 |
/** |
| 1053 |
* Internal dependencies |
| 1054 |
*/ |
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
/** |
| 1059 |
* Appends arguments as querystring to the provided URL. If the URL already |
| 1060 |
* includes query arguments, the arguments are merged with (and take precedent |
| 1061 |
* over) the existing set. |
| 1062 |
* |
| 1063 |
* @param {string} [url=''] URL to which arguments should be appended. If omitted, |
| 1064 |
* only the resulting querystring is returned. |
| 1065 |
* @param {Object} [args] Query arguments to apply to URL. |
| 1066 |
* |
| 1067 |
* @example |
| 1068 |
* ```js |
| 1069 |
* const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test |
| 1070 |
* ``` |
| 1071 |
* |
| 1072 |
* @return {string} URL with arguments applied. |
| 1073 |
*/ |
| 1074 |
function addQueryArgs(url = '', args) { |
| 1075 |
// If no arguments are to be appended, return original URL. |
| 1076 |
if (!args || !Object.keys(args).length) { |
| 1077 |
return url; |
| 1078 |
} |
| 1079 |
let baseUrl = url; |
| 1080 |
|
| 1081 |
// Determine whether URL already had query arguments. |
| 1082 |
const queryStringIndex = url.indexOf('?'); |
| 1083 |
if (queryStringIndex !== -1) { |
| 1084 |
// Merge into existing query arguments. |
| 1085 |
args = Object.assign(getQueryArgs(url), args); |
| 1086 |
|
| 1087 |
// Change working base URL to omit previous query arguments. |
| 1088 |
baseUrl = baseUrl.substr(0, queryStringIndex); |
| 1089 |
} |
| 1090 |
return baseUrl + '?' + buildQueryString(args); |
| 1091 |
} |
| 1092 |
|
| 1093 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-query-arg.js |
| 1094 |
/** |
| 1095 |
* Internal dependencies |
| 1096 |
*/ |
| 1097 |
|
| 1098 |
|
| 1099 |
/** |
| 1100 |
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject |
| 1101 |
*/ |
| 1102 |
|
| 1103 |
/** |
| 1104 |
* @typedef {string|string[]|QueryArgObject} QueryArgParsed |
| 1105 |
*/ |
| 1106 |
|
| 1107 |
/** |
| 1108 |
* Returns a single query argument of the url |
| 1109 |
* |
| 1110 |
* @param {string} url URL. |
| 1111 |
* @param {string} arg Query arg name. |
| 1112 |
* |
| 1113 |
* @example |
| 1114 |
* ```js |
| 1115 |
* const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar |
| 1116 |
* ``` |
| 1117 |
* |
| 1118 |
* @return {QueryArgParsed|void} Query arg value. |
| 1119 |
*/ |
| 1120 |
function getQueryArg(url, arg) { |
| 1121 |
return getQueryArgs(url)[arg]; |
| 1122 |
} |
| 1123 |
|
| 1124 |
;// CONCATENATED MODULE: ./packages/url/build-module/has-query-arg.js |
| 1125 |
/** |
| 1126 |
* Internal dependencies |
| 1127 |
*/ |
| 1128 |
|
| 1129 |
|
| 1130 |
/** |
| 1131 |
* Determines whether the URL contains a given query arg. |
| 1132 |
* |
| 1133 |
* @param {string} url URL. |
| 1134 |
* @param {string} arg Query arg name. |
| 1135 |
* |
| 1136 |
* @example |
| 1137 |
* ```js |
| 1138 |
* const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true |
| 1139 |
* ``` |
| 1140 |
* |
| 1141 |
* @return {boolean} Whether or not the URL contains the query arg. |
| 1142 |
*/ |
| 1143 |
function hasQueryArg(url, arg) { |
| 1144 |
return getQueryArg(url, arg) !== undefined; |
| 1145 |
} |
| 1146 |
|
| 1147 |
;// CONCATENATED MODULE: ./packages/url/build-module/remove-query-args.js |
| 1148 |
/** |
| 1149 |
* Internal dependencies |
| 1150 |
*/ |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
/** |
| 1155 |
* Removes arguments from the query string of the url |
| 1156 |
* |
| 1157 |
* @param {string} url URL. |
| 1158 |
* @param {...string} args Query Args. |
| 1159 |
* |
| 1160 |
* @example |
| 1161 |
* ```js |
| 1162 |
* const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar |
| 1163 |
* ``` |
| 1164 |
* |
| 1165 |
* @return {string} Updated URL. |
| 1166 |
*/ |
| 1167 |
function removeQueryArgs(url, ...args) { |
| 1168 |
const queryStringIndex = url.indexOf('?'); |
| 1169 |
if (queryStringIndex === -1) { |
| 1170 |
return url; |
| 1171 |
} |
| 1172 |
const query = getQueryArgs(url); |
| 1173 |
const baseURL = url.substr(0, queryStringIndex); |
| 1174 |
args.forEach(arg => delete query[arg]); |
| 1175 |
const queryString = buildQueryString(query); |
| 1176 |
return queryString ? baseURL + '?' + queryString : baseURL; |
| 1177 |
} |
| 1178 |
|
| 1179 |
;// CONCATENATED MODULE: ./packages/url/build-module/prepend-http.js |
| 1180 |
/** |
| 1181 |
* Internal dependencies |
| 1182 |
*/ |
| 1183 |
|
| 1184 |
const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; |
| 1185 |
|
| 1186 |
/** |
| 1187 |
* Prepends "http://" to a url, if it looks like something that is meant to be a TLD. |
| 1188 |
* |
| 1189 |
* @param {string} url The URL to test. |
| 1190 |
* |
| 1191 |
* @example |
| 1192 |
* ```js |
| 1193 |
* const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org |
| 1194 |
* ``` |
| 1195 |
* |
| 1196 |
* @return {string} The updated URL. |
| 1197 |
*/ |
| 1198 |
function prependHTTP(url) { |
| 1199 |
if (!url) { |
| 1200 |
return url; |
| 1201 |
} |
| 1202 |
url = url.trim(); |
| 1203 |
if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) { |
| 1204 |
return 'http://' + url; |
| 1205 |
} |
| 1206 |
return url; |
| 1207 |
} |
| 1208 |
|
| 1209 |
;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri.js |
| 1210 |
/** |
| 1211 |
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if |
| 1212 |
* `decodeURI` throws an error. |
| 1213 |
* |
| 1214 |
* @param {string} uri URI to decode. |
| 1215 |
* |
| 1216 |
* @example |
| 1217 |
* ```js |
| 1218 |
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' |
| 1219 |
* ``` |
| 1220 |
* |
| 1221 |
* @return {string} Decoded URI if possible. |
| 1222 |
*/ |
| 1223 |
function safeDecodeURI(uri) { |
| 1224 |
try { |
| 1225 |
return decodeURI(uri); |
| 1226 |
} catch (uriError) { |
| 1227 |
return uri; |
| 1228 |
} |
| 1229 |
} |
| 1230 |
|
| 1231 |
;// CONCATENATED MODULE: ./packages/url/build-module/filter-url-for-display.js |
| 1232 |
/** |
| 1233 |
* Returns a URL for display. |
| 1234 |
* |
| 1235 |
* @param {string} url Original URL. |
| 1236 |
* @param {number|null} maxLength URL length. |
| 1237 |
* |
| 1238 |
* @example |
| 1239 |
* ```js |
| 1240 |
* const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg |
| 1241 |
* const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png |
| 1242 |
* ``` |
| 1243 |
* |
| 1244 |
* @return {string} Displayed URL. |
| 1245 |
*/ |
| 1246 |
function filterURLForDisplay(url, maxLength = null) { |
| 1247 |
// Remove protocol and www prefixes. |
| 1248 |
let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); |
| 1249 |
|
| 1250 |
// Ends with / and only has that single slash, strip it. |
| 1251 |
if (filteredURL.match(/^[^\/]+\/$/)) { |
| 1252 |
filteredURL = filteredURL.replace('/', ''); |
| 1253 |
} |
| 1254 |
const mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/; |
| 1255 |
if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) { |
| 1256 |
return filteredURL; |
| 1257 |
} |
| 1258 |
|
| 1259 |
// If the file is not greater than max length, return last portion of URL. |
| 1260 |
filteredURL = filteredURL.split('?')[0]; |
| 1261 |
const urlPieces = filteredURL.split('/'); |
| 1262 |
const file = urlPieces[urlPieces.length - 1]; |
| 1263 |
if (file.length <= maxLength) { |
| 1264 |
return '…' + filteredURL.slice(-maxLength); |
| 1265 |
} |
| 1266 |
|
| 1267 |
// If the file is greater than max length, truncate the file. |
| 1268 |
const index = file.lastIndexOf('.'); |
| 1269 |
const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)]; |
| 1270 |
const truncatedFile = fileName.slice(-3) + '.' + extension; |
| 1271 |
return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile; |
| 1272 |
} |
| 1273 |
|
| 1274 |
// EXTERNAL MODULE: ./node_modules/remove-accents/index.js |
| 1275 |
var remove_accents = __webpack_require__(4793); |
| 1276 |
var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); |
| 1277 |
;// CONCATENATED MODULE: ./packages/url/build-module/clean-for-slug.js |
| 1278 |
/** |
| 1279 |
* External dependencies |
| 1280 |
*/ |
| 1281 |
|
| 1282 |
|
| 1283 |
/** |
| 1284 |
* Performs some basic cleanup of a string for use as a post slug. |
| 1285 |
* |
| 1286 |
* This replicates some of what `sanitize_title()` does in WordPress core, but |
| 1287 |
* is only designed to approximate what the slug will be. |
| 1288 |
* |
| 1289 |
* Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin |
| 1290 |
* letters. Removes combining diacritical marks. Converts whitespace, periods, |
| 1291 |
* and forward slashes to hyphens. Removes any remaining non-word characters |
| 1292 |
* except hyphens. Converts remaining string to lowercase. It does not account |
| 1293 |
* for octets, HTML entities, or other encoded characters. |
| 1294 |
* |
| 1295 |
* @param {string} string Title or slug to be processed. |
| 1296 |
* |
| 1297 |
* @return {string} Processed string. |
| 1298 |
*/ |
| 1299 |
function cleanForSlug(string) { |
| 1300 |
if (!string) { |
| 1301 |
return ''; |
| 1302 |
} |
| 1303 |
return remove_accents_default()(string) |
| 1304 |
// Convert each group of whitespace, periods, and forward slashes to a hyphen. |
| 1305 |
.replace(/[\s\./]+/g, '-') |
| 1306 |
// Remove anything that's not a letter, number, underscore or hyphen. |
| 1307 |
.replace(/[^\p{L}\p{N}_-]+/gu, '') |
| 1308 |
// Convert to lowercase |
| 1309 |
.toLowerCase() |
| 1310 |
// Replace multiple hyphens with a single one. |
| 1311 |
.replace(/-+/g, '-') |
| 1312 |
// Remove any remaining leading or trailing hyphens. |
| 1313 |
.replace(/(^-+)|(-+$)/g, ''); |
| 1314 |
} |
| 1315 |
|
| 1316 |
;// CONCATENATED MODULE: ./packages/url/build-module/get-filename.js |
| 1317 |
/** |
| 1318 |
* Returns the filename part of the URL. |
| 1319 |
* |
| 1320 |
* @param {string} url The full URL. |
| 1321 |
* |
| 1322 |
* @example |
| 1323 |
* ```js |
| 1324 |
* const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg' |
| 1325 |
* const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png' |
| 1326 |
* ``` |
| 1327 |
* |
| 1328 |
* @return {string|void} The filename part of the URL. |
| 1329 |
*/ |
| 1330 |
function getFilename(url) { |
| 1331 |
let filename; |
| 1332 |
try { |
| 1333 |
filename = new URL(url, 'http://example.com').pathname.split('/').pop(); |
| 1334 |
} catch (error) {} |
| 1335 |
if (filename) { |
| 1336 |
return filename; |
| 1337 |
} |
| 1338 |
} |
| 1339 |
|
| 1340 |
;// CONCATENATED MODULE: ./packages/url/build-module/normalize-path.js |
| 1341 |
/** |
| 1342 |
* Given a path, returns a normalized path where equal query parameter values |
| 1343 |
* will be treated as identical, regardless of order they appear in the original |
| 1344 |
* text. |
| 1345 |
* |
| 1346 |
* @param {string} path Original path. |
| 1347 |
* |
| 1348 |
* @return {string} Normalized path. |
| 1349 |
*/ |
| 1350 |
function normalizePath(path) { |
| 1351 |
const splitted = path.split('?'); |
| 1352 |
const query = splitted[1]; |
| 1353 |
const base = splitted[0]; |
| 1354 |
if (!query) { |
| 1355 |
return base; |
| 1356 |
} |
| 1357 |
|
| 1358 |
// 'b=1%2C2&c=2&a=5' |
| 1359 |
return base + '?' + query |
| 1360 |
// [ 'b=1%2C2', 'c=2', 'a=5' ] |
| 1361 |
.split('&') |
| 1362 |
// [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ] |
| 1363 |
.map(entry => entry.split('=')) |
| 1364 |
// [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ] |
| 1365 |
.map(pair => pair.map(decodeURIComponent)) |
| 1366 |
// [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ] |
| 1367 |
.sort((a, b) => a[0].localeCompare(b[0])) |
| 1368 |
// [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ] |
| 1369 |
.map(pair => pair.map(encodeURIComponent)) |
| 1370 |
// [ 'a=5', 'b=1%2C2', 'c=2' ] |
| 1371 |
.map(pair => pair.join('=')) |
| 1372 |
// 'a=5&b=1%2C2&c=2' |
| 1373 |
.join('&'); |
| 1374 |
} |
| 1375 |
|
| 1376 |
;// CONCATENATED MODULE: ./packages/url/build-module/prepend-https.js |
| 1377 |
/** |
| 1378 |
* Internal dependencies |
| 1379 |
*/ |
| 1380 |
|
| 1381 |
|
| 1382 |
/** |
| 1383 |
* Prepends "https://" to a url, if it looks like something that is meant to be a TLD. |
| 1384 |
* |
| 1385 |
* Note: this will not replace "http://" with "https://". |
| 1386 |
* |
| 1387 |
* @param {string} url The URL to test. |
| 1388 |
* |
| 1389 |
* @example |
| 1390 |
* ```js |
| 1391 |
* const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org |
| 1392 |
* ``` |
| 1393 |
* |
| 1394 |
* @return {string} The updated URL. |
| 1395 |
*/ |
| 1396 |
function prependHTTPS(url) { |
| 1397 |
if (!url) { |
| 1398 |
return url; |
| 1399 |
} |
| 1400 |
|
| 1401 |
// If url starts with http://, return it as is. |
| 1402 |
if (url.startsWith('http://')) { |
| 1403 |
return url; |
| 1404 |
} |
| 1405 |
url = prependHTTP(url); |
| 1406 |
return url.replace(/^http:/, 'https:'); |
| 1407 |
} |
| 1408 |
|
| 1409 |
;// CONCATENATED MODULE: ./packages/url/build-module/index.js |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
})(); |
| 1439 |
|
| 1440 |
(window.wp = window.wp || {}).url = __webpack_exports__; |
| 1441 |
/******/ })() |
| 1442 |
; |