question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Abijeetcommented, Dec 3, 2017

@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

0reactions
stale[bot]commented, Apr 24, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

All About Slugs (Not the Slimy Kind) | The Daily Post
No punctuation. Slugs are lowercase letters and numbers only. Punctuation will be automatically removed, which could leave you with meaningless ...
Read more >
Make slug fields optional for all models · Issue #8113 · netbox ...
Using names, you add additional formatting potential (punctuation, additional characters, etc) which aren't allowed in a slug field.
Read more >
How to Fix WordPress Page Slug Not Updating - Convology
There are two main reasons why WordPress page slugs, or the URL of the page in WordPress, won't edit even if you go...
Read more >
How to convert a Title to a URL slug in jQuery? - Stack Overflow
What I'd like to do is remove the punctuation, convert it to lowercase, and replace the spaces with hyphens.
Read more >
slug - Apostrophe 3 Documentation
Text entered in a slug field is immediately lower-cased and all spaces and punctuation are replaced by dashes ( - ).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found