cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From riknoll <...@git.apache.org>
Subject [GitHub] cordova-docs pull request: Reverse-engineering GitHub's slugifying...
Date Thu, 03 Mar 2016 01:45:36 GMT
Github user riknoll commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/532#discussion_r54825004
  
    --- Diff: www/static/js/docs.js ---
    @@ -17,19 +17,30 @@
     
     $(document).ready(function () {
     
    -    function slugify(text) {
    +    function slugifyLikeGitHub(originalText) {
    +
    +        var text = originalText;
    +
    +        // convert to lowercase
             text = text.toLowerCase();
     
    -        // replace unaccepted characters with spaces
    +        // replace whitespace characters with dashes
    +        text = text.replace(/\s/g, '-');
    +
    +        // remove dashes at the start and end if they weren't there since the start
    --- End diff --
    
    If they weren't there from the start? What about these two cases:
    ```
    "  -hello" => "--hello"
    "   hello" => "hello"
    ```
    Is that right? Should the first example work out that way with the extra dash? Seems like
`trim()` should maybe get called before the first replace


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message