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

Hardcoded slash #17

Open
moonlik opened this issue Jun 16, 2017 · 4 comments
Open

Hardcoded slash #17

moonlik opened this issue Jun 16, 2017 · 4 comments

Comments

@moonlik
Copy link

moonlik commented Jun 16, 2017

I don't know why but you still keep to hard code the slash in your code. And I think the slash in the code below is not needed because you can input the slash in urlPrefix.

urlBuilder: {
      type: Function,
      default (page) {
        return this.normalize(`${this.urlPrefix}/${page}`)
      }
    },

Why do you want to keep this slash between ${this.urlPrefix} and ${page}?

@korzhyk
Copy link
Contributor

korzhyk commented Jul 4, 2017

/ keeped for backward compatibility and there a #normalize() which remove duplicated slashes. If you are using a custom #urlBuilder() you can do what you want.

@moonlik
Copy link
Author

moonlik commented Aug 7, 2017

@korzhyk but in my use case I need to put the page number not after slash, but after ?page=. So the string ?page= is my prefix. And it doesn't need any additional slashes.

<pagination v-bind:urlPrefix="'?page='"
    v-bind:currentPage="parseInt(query.page)"
    v-bind:lastPage="lastPage"
    v-bind:displayPage="5"
    class="is-small" />

But slash is hardcoded here. It's a very unflexible solution.

I propose another way:
urlPrefix is a prefix which can include any characters. If somebody needs to add slash let him put this slash directly in his prefix (for example, urlPrefix='page/'), which won't affect others who have another URL formats (for example, urlPrefix='?page=').

@korzhyk
Copy link
Contributor

korzhyk commented Aug 7, 2017

<router-link :class="getPreClassName()" :to="normalize(urlPrefix+'/'+(formatCurrentPage-1))" >{{prev}}</router-link>

So, I faced with this problem before contribute #urlBuilder() too. And as you can see urlBuilder resolve this issue as well.

<pagination v-bind:urlBuilder="page => ({ query: { page } })"
    v-bind:currentPage="parseInt(query.page)"
    v-bind:lastPage="lastPage"
    v-bind:displayPage="5"
    class="is-small" />

ℹ️ Hardcoded slash placed for backward compatibility.

@moonlik
Copy link
Author

moonlik commented Aug 8, 2017

@korzhyk Oh, I see. Thank you for your help! Everything is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants