-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No encode, decode in createLocation (#465)
* Do not encode pathnames, decode in createLocation * Throw when creating bad path, warn for bad location * Rethrow with clearer message on URIError * Throw URIError, add tests to memory history * Remove unnecessary test case * Add note to CHANGES.md
- Loading branch information
Showing
13 changed files
with
261 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## HEAD | ||
|
||
- Rely on the user/browser to encode pathname portion of the URL. | ||
|
||
## [v4.6.1] | ||
> Mar 15, 2017 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
modules/__tests__/TestSequences/EncodedReservedCharacters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import expect from 'expect' | ||
import execSteps from './execSteps' | ||
|
||
export default (history, done) => { | ||
const steps = [ | ||
() => { | ||
// encoded string | ||
const pathname = '/view/%23abc' | ||
history.replace(pathname) | ||
}, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/view/%23abc' | ||
}) | ||
|
||
// encoded object | ||
const pathname = '/view/%23abc' | ||
history.replace({ pathname }) | ||
}, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/view/%23abc' | ||
}) | ||
// unencoded string | ||
const pathname = '/view/#abc' | ||
history.replace(pathname) | ||
} | ||
, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/view/', | ||
hash: '#abc' | ||
}) | ||
} | ||
] | ||
|
||
execSteps(steps, history, done) | ||
} |
45 changes: 45 additions & 0 deletions
45
modules/__tests__/TestSequences/LocationPathnameAlwaysDecoded.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import expect from 'expect' | ||
import execSteps from './execSteps' | ||
|
||
export default (history, done) => { | ||
const steps = [ | ||
() => { | ||
// encoded string | ||
const pathname = '/%E6%AD%B4%E5%8F%B2' | ||
history.replace(pathname) | ||
}, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/歴史' | ||
}) | ||
|
||
// encoded object | ||
const pathname = '/%E6%AD%B4%E5%8F%B2' | ||
history.replace({ pathname }) | ||
}, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/歴史' | ||
}) | ||
// unencoded string | ||
const pathname = '/歴史' | ||
history.replace(pathname) | ||
} | ||
, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/歴史' | ||
}) | ||
// unencoded object | ||
const pathname = '/歴史' | ||
history.replace({ pathname }) | ||
}, | ||
(location) => { | ||
expect(location).toMatch({ | ||
pathname: '/歴史' | ||
}) | ||
} | ||
] | ||
|
||
execSteps(steps, history, done) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import expect from 'expect' | ||
import execSteps from './execSteps' | ||
|
||
export default (history, done) => { | ||
const steps = [ | ||
() => { | ||
expect(() => { | ||
history.push('/hello%') | ||
}).toThrow( | ||
'Pathname "/hello%" could not be decoded. This is likely caused by an invalid percent-encoding.' | ||
) | ||
} | ||
] | ||
|
||
execSteps(steps, history, done) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import expect from 'expect' | ||
import execSteps from './execSteps' | ||
|
||
export default (history, done) => { | ||
const steps = [ | ||
() => { | ||
expect(() => { | ||
history.replace('/hello%') | ||
}).toThrow( | ||
'Pathname "/hello%" could not be decoded. This is likely caused by an invalid percent-encoding.' | ||
) | ||
} | ||
] | ||
|
||
execSteps(steps, history, done) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.