jashkenas / jashkenas/backbone
Trailing Fragment Space(s)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 28.1k
- Forks
- 5.3k
- PR merge metrics
- No merged PRs in 30d
Description
We have fragments that have a space at the end (outbound/22130600/po/powithspacetest%20). When trying to navigate to this fragment Backbone is stripping the trailing space in getFragment().
var M = /^[#\/]|\s+$/g;
getFragment: function(t) {
if (t == null) {
if (this._usePushState || !this._wantsHashChange) {
t = this.getPath()
} else {
t = this.getHash()
}
}
return t.replace(M, "")
},
I can understand removing the bits at the start of the fragment, but can someone explain the motivation for removing the space(s) at the end? This causes our app to fail to lookup the requested data because the part with the space is a param in the router.
routes: {
"": "home",
"outbound/:tieBack/po/:poNbr": "outboundDetail"
},
And
outboundDetail: function(tieBack, poNbr) {
app.switchOutboundDetail(tieBack, poNbr);
},
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the getFragment entry point and inspect the M regular expression shown in the issue, then trace how the returned fragment reaches the outbound/:tieBack/po/:poNbr route. Confirm the expected behavior for a trailing-space parameter and add coverage demonstrating that the router receives the intended value without breaking existing fragment handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100