Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#44764 closed defect (bug) (fixed)

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

Reported by: ocean90's profile ocean90 Owned by: kadamwhite's profile 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 6 years ago.
Slash Fix
44764.diff (438 bytes) - added by kadamwhite 6 years ago.

Download all attachments as: .zip

Change History (10)

@abdullahramzan
6 years ago

Slash Fix

#1 @abdullahramzan
6 years ago

  • Keywords has-patch added; needs-patch removed

#2 @kadamwhite
6 years 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
6 years ago

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


6 years ago

#4 @kadamwhite
6 years ago

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

#5 @kadamwhite
6 years ago

  • Keywords commit added; needs-unit-tests removed

#6 @kadamwhite
6 years 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
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

[43566] should be backported to the 5.0 branch.

#8 @danielbachhuber
6 years 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.