Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve internal route and parameter parsing #330

Merged
merged 32 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c11c150
Tokenize all route template parameter segments (e.g. `{post?}`) into …
bakerkretzmar Sep 5, 2020
689d2d6
Fix default parameter assignment and merging, formatting
bakerkretzmar Sep 6, 2020
ac682c6
Refactor core parameter matching logic:
bakerkretzmar Sep 6, 2020
d072487
Replace UrlBuilder class with simplified getters on main Router class
bakerkretzmar Sep 6, 2020
718a347
Formatting
bakerkretzmar Sep 7, 2020
84e07d1
Add support for parsing query parameters out of current URL, formatti…
bakerkretzmar Sep 11, 2020
11a4ed4
Merge branch 'develop' into jbk/tokens
bakerkretzmar Sep 11, 2020
d1332fb
Re-implement current route checking with full support for partially m…
bakerkretzmar Sep 11, 2020
acf80de
Cleanup
bakerkretzmar Sep 17, 2020
b0dac39
Enable microbundle property mangling to reduce size and restrict inte…
bakerkretzmar Sep 17, 2020
c5aced6
Formatting, errors, organization, and comments
bakerkretzmar Sep 18, 2020
7148061
Remove `exact` flag from `current()`
bakerkretzmar Sep 18, 2020
a843963
Add tests for errors, strings, and bindings
bakerkretzmar Sep 18, 2020
fb88075
:)
bakerkretzmar Sep 18, 2020
c22342c
Update description and tightenco → tighten
bakerkretzmar Sep 18, 2020
a6c4101
Remove comment
bakerkretzmar Sep 18, 2020
483e13b
Cleanup
bakerkretzmar Sep 18, 2020
84e4956
Collapse everything into a simple new Route class
bakerkretzmar Sep 18, 2020
e8d1141
Clean up formatting and comments, rename _locationURL to _dehydrate
bakerkretzmar Sep 25, 2020
c553ce6
Check for Ziggy config on `globalThis` as a fallback
bakerkretzmar Sep 25, 2020
0d69f1c
Remove tests for removed/deprecated methods
bakerkretzmar Sep 25, 2020
81947eb
Parse the current URL once instead of for each route
bakerkretzmar Sep 25, 2020
d670e33
Make config and queryParams private
bakerkretzmar Sep 25, 2020
6089779
Revert "Update description and tightenco → tighten"
bakerkretzmar Sep 25, 2020
8053766
Merge branch 'develop' into jbk/tokens
bakerkretzmar Sep 25, 2020
e024de6
Update Changelog
bakerkretzmar Sep 25, 2020
f38eea2
Add and improve comments, rename/reorder methods
bakerkretzmar Oct 2, 2020
7ec8140
Add implicit test coverage for default parameters
bakerkretzmar Oct 2, 2020
644e021
Merge branch 'develop' into jbk/tokens
bakerkretzmar Oct 2, 2020
4a3fa81
Allow fallback route model 'binding' of 'id' to increase backwards co…
bakerkretzmar Oct 9, 2020
7c95d02
Formatting
bakerkretzmar Oct 9, 2020
85ff2f6
Typo
bakerkretzmar Oct 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Breaking changes are marked with ⚠️.
- Document the `check()` method ([#294](https://github.com/tighten/ziggy/pull/294)) and how to install and use Ziggy via `npm` and over a CDN ([#299](https://github.com/tighten/ziggy/pull/299))
- Add support for [custom scoped route model binding](https://laravel.com/docs/7.x/routing#implicit-binding), e.g. `/users/{user}/posts/{post:slug}` ([#307](https://github.com/tighten/ziggy/pull/307))
- Add support for [implicit route model binding](https://laravel.com/docs/7.x/routing#implicit-binding) ([#315](https://github.com/tighten/ziggy/pull/315))
- Add support for passing parameters to `current()` to check against the current URL in addition to the route name ([#330](https://github.com/tighten/ziggy/pull/330))

**Changed**

Expand All @@ -26,10 +27,19 @@ Breaking changes are marked with ⚠️.
- Use Jest instead of Mocha for JS tests ([#309](https://github.com/tighten/ziggy/pull/309))
- Use [microbundle](https://github.com/developit/microbundle) instead of Webpack to build and distribute Ziggy ([#312](https://github.com/tighten/ziggy/pull/312))
- ⚠️ Default Ziggy's `baseUrl` to the value of the `APP_URL` environment variable instead of `url('/')` ([#334](https://github.com/tighten/ziggy/pull/334))
- ⚠️ Allow getting the route name with `current()` when the current URL has a query string ([#330](https://github.com/tighten/ziggy/pull/330))

**Deprecated**

- Deprecate the `with()` and `check()` methods ([#330](https://github.com/tighten/ziggy/pull/330))

**Removed**

- ⚠️ Remove `Route` Facade macros `Route::only()` and `Route::except()` (previously `Route::whitelist()` and `Route::blacklist()`) ([#306](https://github.com/tighten/ziggy/pull/306))
- ⚠️ Remove the following undocumented public properties and methods from the `Router` class returned by the `route()` function ([#330](https://github.com/tighten/ziggy/pull/330)):
- `name`, `absolute`, `ziggy`, `urlBuilder`, `template`, `urlParams`, `queryParams`, and `hydrated`
- `normalizeParams()`, `hydrateUrl()`, `matchUrl()`, `constructQuery()`, `extractParams()`, `parse()`, and `trimParam()`
- ⚠️ Remove the `UrlBuilder` class ([#330](https://github.com/tighten/ziggy/pull/330)):

**Fixed**

Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "ziggy-js",
"version": "0.9.1",
"description": "Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.",
"description": "Use your Laravel named routes in JavaScript.",
"keywords": [
"laravel",
"routes",
"ziggy"
],
"homepage": "https://github.com/tighten/ziggy#readme",
"homepage": "https://github.com/tighten/ziggy",
"bugs": "https://github.com/tighten/ziggy/issues",
"license": "MIT",
"authors": [
Expand All @@ -18,6 +18,10 @@
{
"name": "Jake Bathman",
"email": "[email protected]"
},
{
"name": "Jacob Baker-Kretzmar",
"email": "[email protected]"
}
],
"files": [
Expand All @@ -40,6 +44,9 @@
"test": "jest",
"prepublishOnly": "npm run build"
},
"mangle": {
"regex": "^_"
},
"dependencies": {
"qs": "^6.8.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Ziggy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(string $group = null, string $url = null)
{
$this->group = $group;

$this->baseUrl = Str::finish($url ?? config('app.url', url('/')), '/');
$this->baseUrl = rtrim($url ?? config('app.url', url('/')), '/');

tap(parse_url($this->baseUrl), function ($url) {
$this->baseProtocol = $url['scheme'] ?? 'http';
Expand Down
40 changes: 0 additions & 40 deletions src/js/UrlBuilder.js

This file was deleted.

Loading