Skip to content

Commit 76411bc

Browse files
committed
Manually parse page number from URL
1 parent b75c524 commit 76411bc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/controllers/group/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ import Pagination from 'ember-cli-jsonapi-pagination/mixins/controllers/jsonapi-
33

44
export default Ember.Controller.extend(Pagination, {
55
totalPages: Ember.computed('size', 'number', 'model.posts.[]', function() {
6-
const lastPage = new URL(this.get("posts.links.last"));
7-
return parseInt(lastPage.searchParams.get("page[number]"));
6+
return parseInt(getParameterByName("page[number]", this.get("posts.links.last")));
87
})
98
});
9+
10+
function getParameterByName(name, url) {
11+
name = encodeURIComponent(name);
12+
const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
13+
const results = regex.exec(url);
14+
15+
if (!results) return null;
16+
if (!results[2]) return "";
17+
18+
return decodeURIComponent(results[2].replace(/\+/g, " "));
19+
}

0 commit comments

Comments
 (0)