hedgedoc / cli

A tiny CLI for HedgeDoc
GNU Affero General Public License v3.0
150 stars 37 forks source link

Fix import command returning redirect message instead of note id #31

Closed davidak closed 4 years ago

davidak commented 4 years ago
Options:
    $ codimd import /path/to/your/content.md
    qhmNmwmxSmK1H2oJmkKBQQ       # returns note id on success

but the actual output is

Found. Redirecting to https://pad.nixnet.services/yN-Ji4YeTNaZuhci23IsFQ

pirate commented 4 years ago

I think rather than change the docs it would be better to fix the output so that it returns the note id correctly. It's actually already supposed to be returning just the note id, the perl-based redirect parsing is just broken for some reason, see here:

https://github.com/codimd/cli/blob/master/bin/codimd#L61

davidak commented 4 years ago

I think the URL is more useful to work with later. But that would be a breaking change. Maybe make a 0.1 release now and change it and mention it in the release notes of 0.2.

Related issue: https://github.com/codimd/cli/issues/33

pirate commented 4 years ago

The reason I decided against URL in favor of just the path is that it's easier to concat $CODIMD_SERVER/$note_id yourself than to remove the server url prefix from the output. Also we run one server listening on many domains simultaneously, so we use those note ids independent of whatever base domain the server happens to be accessed from.

pirate commented 4 years ago

Fixed in https://github.com/codimd/cli/commit/83d913ef468d738a2f1bd44c1d90b29ff8e6a4d5