Clarify pathname docs, follow spec with fragments (#2448)

* Clarify pathname docs, follow spec with fragments

- Valid URLs must not contain a `#` within its fragment.
  https://github.com/MithrilJS/mithril.js/issues/2445
- Our docs were a little confusing and misleading - `m.pathname` isn't
  aware of URLs, just path names.
- Removed the relevant extension to `m.parseQueryString` required to
  support the hash parsing extension. Now we just shave it off and
  ignore it.
- Fix support for arbitrary prefixes, so prefixes like `?#` are
  handled correctly.
- Add a bunch of tests to cover various areas of confusion and unusual
  edge cases.

* Update with PR [skip ci]
This commit is contained in:
Isiah Meadows 2019-07-03 06:22:25 -04:00 committed by GitHub
parent 9e9b89d900
commit 85bfd0f77d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 85 additions and 127 deletions

View file

@ -198,18 +198,6 @@ o.spec("compileTemplate", function() {
o(compileTemplate("/route/:id?bar=foo")(data)).equals(false)
o(data.params).deepEquals({foo: "bar"})
})
o("checks hash params match", function() {
var data = parsePathname("/route/1#foo=bar")
o(compileTemplate("/route/:id#foo=bar")(data)).equals(true)
o(data.params).deepEquals({id: "1", foo: "bar"})
})
o("checks hash params mismatch", function() {
var data = parsePathname("/route/1#foo=bar")
o(compileTemplate("/route/:id#foo=1")(data)).equals(false)
o(data.params).deepEquals({foo: "bar"})
o(compileTemplate("/route/:id#bar=foo")(data)).equals(false)
o(data.params).deepEquals({foo: "bar"})
})
o("checks dot before dot", function() {
var data = parsePathname("/file.test.png/edit")
o(compileTemplate("/:file.:ext/edit")(data)).equals(true)