Skip to content

Commit ffbedef

Browse files
authored
Fix #15
1 parent a34df82 commit ffbedef

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/request.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,37 @@ The parameter to `options.extract` is the XMLHttpRequest object once its operati
475475

476476
---
477477

478+
### Issuing fetches to IP addresses
479+
480+
Due to the (very simplistic) way parameters are detected in URLs, IPv6 address segments are confused as path parameter interpolations, and as path parameters need something to separate them to be interpolated correctly, this results in an error being thrown.
481+
482+
```javascript
483+
// This doesn't work
484+
m.request("http://[2001:db8::990a:cd27:4d9e:79]:8080/some/path", {
485+
// ...
486+
})
487+
```
488+
489+
To work around this, you should pass the IPv6 address + port pair as a parameter instead.
490+
491+
```javascript
492+
m.request("http://:host/some/path", {
493+
params: {host: "[2001:db8::990a:cd27:4d9e:79]:8080"},
494+
// ...
495+
})
496+
```
497+
498+
This is not an issue with IPv4 addresses, and you can use those normally.
499+
500+
```javascript
501+
// This will work as you expect
502+
m.request("http://192.0.2.15:8080/some/path", {
503+
// ...
504+
})
505+
```
506+
507+
---
508+
478509
### Why JSON instead of HTML
479510

480511
Many server-side frameworks provide a view engine that interpolates database data into a template before serving HTML (on page load or via AJAX) and then employ jQuery to handle user interactions.

0 commit comments

Comments
 (0)