Skip to content

PatternUtils.formatPattern replaces encoded space (%20) with + #2407

@coopy

Description

@coopy

This line causes a URL parameter to be encoded in a non-reversible way: https://github.com/rackt/react-router/blob/v1.0.0-rc3/modules/PatternUtils.js#L170

We have an IIS server that doesn't correctly resolve URLs because of this behavior.

The change was introduced here: d955d7a

I'd like to know the reason that this behavior was introduced, as it's somewhat unexpected. To quote @mjackson:

Apparently + is a special character in query strings, but not in the path portion of the URL.
#716 (comment)

I've not been able to find conclusive evidence in the URI spec, but considering that encoding and decoding should be symmetrical operations, this seems wrong. There is some discussion in this Stackoverflow thread.

Example:

var placeName = 'Laguna Beach';
var uri = formatPattern('/place/:placeName', { placeName: placeName });
decodeURI(uri);
// -> "/place/Laguna+Beach"
// Expected decoded URI would be "/place/Laguna Beach".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions