Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#40111 closed defect (bug) (wontfix)

WP REST API Decode Slug URL

Reported by: yogevlahyani's profile yogevlahyani Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords: reporter-feedback
Focuses: Cc:

Description

Hello, I was trying to decode the url on my frontend but didn't manage to do it.
I get the slug as "%d7%a9%d7%9c%d7%95%d7%9d-%d7%a2%d7%95%d7%9c%d7%9d" and I was trying to decode it on the backend but didn't figure out how

Change History (3)

#1 follow-up: @SergeyBiryukov
8 years ago

  • Component changed from General to REST API
  • Keywords reporter-feedback added

Hi @yogevlahyani, welcome to WordPress Trac!

That's how UTF-8 characters are represented in URLs, see https://en.wikipedia.org/wiki/Percent-encoding. They can be decoded with urldecode() PHP function.

Could you clarify the issue you are running into and provide the steps to reproduce it on a clean install?

#2 in reply to: ↑ 1 @yogevlahyani
8 years ago

Hi @SergeyBiryukov, Thank you for replying.
I know how to decode the url but I was not able to find the code in plugins/rest-api folder.

BTW if it matters I am using those plugins together:
WP REST API
WP REST API Toolbox
WP REST API Menus
Better REST API Featured Images
ACF Pro
ACF to WP REST API

#3 @rmccue
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This has previously been discussed; slugs are specifically for URLs, and as such, can only contain characters valid for URLs. All other characters must be encoded using percent-encoding.

In your API client, you can use urldecode() for PHP, decodeURIComponent() for JS, or similar for other languages.

Note: See TracTickets for help on using tickets.