WordPress.org

Make WordPress Core

#44764 closed defect (bug) (fixed)

Missing slash between protocol and domain in fallback of wp.api.utils.getRootUrl()

Reported by: ocean90 Owned by: kadamwhite
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: good-first-bug has-patch commit
Focuses: javascript, rest-api Cc:

Description

If window.location.origin isn't set, getRootUrl() falls back to window.location.protocol, a single slash and window.location.host. The result of this is an URL with one missing slash between the protocol and the domain because window.location.protocol only contains the protocol and the colon. Example output: http:/localhost:3000/

Attachments (2)

44764.1.diff (1.0 KB) - added by abdullahramzan 20 months ago.
Slash Fix
44764.diff (438 bytes) - added by kadamwhite 20 months ago.

Download all attachments as: .zip

Change History (10)

@abdullahramzan
20 months ago

Slash Fix

#1 @abdullahramzan
20 months ago

  • Keywords has-patch added; needs-patch removed

#2 @kadamwhite
20 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from Future Release to 5.0
  • Owner set to kadamwhite
  • Status changed from new to accepted

@kadamwhite
20 months ago

This ticket was mentioned in Slack in #core-restapi by kadamwhite. View the logs.


20 months ago

#4 @kadamwhite
20 months ago

Refreshed patch to apply cleanly on the develop repo. Looks good, @abdullahramzan, thank you for tackling this!

#5 @kadamwhite
20 months ago

  • Keywords commit added; needs-unit-tests removed

#6 @kadamwhite
20 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 43566:

REST API: generate a valid fallback URI in wp.api.utils.getRootURL.

When window.location.origin isn't set, correctly insert two slashes between the protocol and host when constructing the fallback URL.

props abdullahramzan.
Fixes #44764.

#7 @SergeyBiryukov
18 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

[43566] should be backported to the 5.0 branch.

#8 @danielbachhuber
18 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 43757:

REST API: generate a valid fallback URI in wp.api.utils.getRootURL.

When window.location.origin isn't set, correctly insert two slashes between the protocol and host when constructing the fallback URL.

Props abdullahramzan.
Merges [43566] into the 5.0 branch.
Fixes #44764.

Note: See TracTickets for help on using tickets.