Automattic / Automattic/wp-api-console

Escaping `/` and `::` in endpoint URLs

Open
#44 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
73
Forks
23
PR merge metrics
No merged PRs in 30d

Description

I tested out Jetpack sites installed into subdomains. In the existing (old) console it is pretty badly broken, but it is mostly working correctly here.

### Test cases

#### v1 API; enter `make.wordpress.org/core` into site field

![image](https://cloud.githubusercontent.com/assets/227022/20320308/14bfc3de-ab37-11e6-8d27-3089680e5e1d.png)

This does not work - it sends a request to `v1.1/sites/make.wordpress.org/core/posts/` which is a 404 of course.

#### v1 API; enter `make.wordpress.org%2Fcore` into site field

This works correctly.

#### v1 API; enter `make.wordpress.org/core` into URL directly

![image](https://cloud.githubusercontent.com/assets/227022/20320389/51132218-ab37-11e6-9987-2f3197d8016c.png)

This does not work, and we shouldn't expect it to work. There's no reliable way to tell that this is a URL for the `/posts` endpoint.

#### v1 API; enter `make.wordpress.org%2Fcore` into URL directly

This works correctly.

#### v1 API; enter `make.wordpress.org::core` into site field or into URL directly

This is sent to the server correctly, but the v1 API does not support it.

#### v2 API; enter `make.wordpress.org/core` or `make.wordpress.org%2Fcore`

This is sent to the server in the same way as the v1 API, but the v2 API does not support it.

#### v2 API; enter `make.wordpress.org::core` into site field or into URL directly

This works correctly.

### Potential improvements

1. If `/` is entered into a `site` URL field, transform it into `%2F`
2. If `::` is entered for the v1 API, transform it into `%2F`
3. If `/` or `%2F` are entered for the v2 API, transform it into `::`

Contributor guide

No contributing guide indexed for this repository

Research direction

No files or tests are named. Reproduce the listed v1 and v2 site-field and direct-URL cases in the React API console, then trace where endpoint URLs are assembled. Done means slash and double-colon inputs are converted appropriately for each API version and the listed requests reach the intended endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.