Ghost: Adding punctuation to the end of a slug doesn't update the slug field

Created on 23 Nov 2017  路  5Comments  路  Source: TryGhost/Ghost

Issue Summary

If you add punctuation to the end of a slug (slug!) so that the server replies with slug-2, the slug field doesn't update and the post is not saved.

Steps to Reproduce

  1. Open web inspector so that network requests are recorded
  2. Open a post in the editor
  3. In the settings menu "Post URL" field, add punctuation to the end of the text then click off of the input so it updates

    • eg, if the existing slug was hello, you would put hello! in the URL field

    • there should be a GET request to get a slug from the server, if you look at the response it should be something like hello-2

  4. Note that the punctuation is still shown in the URL field and that no PUT request was made to update the post

Technical details:

  • Ghost Version: 1.18.0
  • Browser/OS: Chrome/macOS
admin client bug good first issue help wanted stale

Most helpful comment

@kevinansfield - I've investigated the issue some and here's what I've found.

  1. When I put hello! in the slug field, it returns hello-2
  2. This code (https://github.com/TryGhost/Ghost-Admin/blob/master/app/mixins/editor-base-controller.js#L255) ensures that the put request to update the slug does not occur,
        // if the candidate slug is the same as the existing slug except
        // for the incrementor then the existing slug should be used
        if (isNumber(check) && check > 0) {
            if (slug === slugTokens.join('-') && serverSlug !== newSlug) {
                this.set('slugValue', slug);

                return;
            }
        }

I'm not sure what the expected behaviour is here. The original change there was made as part of this commit - https://github.com/TryGhost/Ghost-Admin/commit/e772430bd6ac8d32ba4029e96087c53e261c182a#diff-30dc1eff6ae6709c67989797bd574a92

All 5 comments

@kevinansfield - I've investigated the issue some and here's what I've found.

  1. When I put hello! in the slug field, it returns hello-2
  2. This code (https://github.com/TryGhost/Ghost-Admin/blob/master/app/mixins/editor-base-controller.js#L255) ensures that the put request to update the slug does not occur,
        // if the candidate slug is the same as the existing slug except
        // for the incrementor then the existing slug should be used
        if (isNumber(check) && check > 0) {
            if (slug === slugTokens.join('-') && serverSlug !== newSlug) {
                this.set('slugValue', slug);

                return;
            }
        }

I'm not sure what the expected behaviour is here. The original change there was made as part of this commit - https://github.com/TryGhost/Ghost-Admin/commit/e772430bd6ac8d32ba4029e96087c53e261c182a#diff-30dc1eff6ae6709c67989797bd574a92

@kevinansfield - Hi, any updates on this? How would you like me to proceed?

@kevinansfield I'd like to take this as my first PR if possible!

This doesn't seem to be a problem with 2.1.4.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings