When testing Gemini I noticed that if your paths have a preceding slash they can be added but not queried.
For example
mysql> select * from Gemini;
+----+------------------------+-------------------+
| id | drupal | fedora |
+----+------------------------+-------------------+
| 1 | /fedora_resource/jared | /container/1 |
| 2 | fedora_resource/22 | container/3 |
| 3 | /fedora_resource/bad | /split_crate/oops |
| 5 | fedora_resource/woot | there/it/is |
+----+------------------------+-------------------+
4 rows in set (0.00 sec)
ubuntu@claw:~$ curl -i http://localhost:8083/drupal/fedora_resource/22
HTTP/1.1 200 OK
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:27:57 GMT
container/3
But
ubuntu@claw:~$ curl -i http://localhost:8083/drupal/fedora_resource/jared
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:29:17 GMT
Or more directly
ubuntu@claw:~$ curl -i -XPOST -H"Content-type: application/json" -d '{ "fedora" : "/my/new/path", "drupal" : "/super/cool" }' http://localhost:8083
HTTP/1.1 201 Created
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:31:48 GMT
ubuntu@claw:~$ curl -i http://localhost:8083/drupal/super/cool
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:32:28 GMT
We should either deal with preceding slashes or throw an error when adding them.
Thoughts?
Hrm, that _should_ have been fixed with https://github.com/Islandora-CLAW/chullo/pull/64 ...I'll have to look closer at Gemini to make sure.
@ruebot oh maybe I didn't pull something in correctly?
@ruebot oh actually this wouldn't be that. This service never touches Fedora or Drupal, so Chullo wouldn't be involved.
It's right here https://github.com/Islandora-CLAW/Crayfish/blob/master/Gemini/src/app.php#L23-L26
> curl -i http://localhost:8083/drupal/super/cool
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:39:11 GMT
But an error_log() inside the getDrupalPath function shows
[Thu Apr 13 14:39:11 2017] drupal path is (super/cool)
That is stripping the front slash off, so when you get to the Path Mapping service you always get an item without a leading slash. So I would say we should just remove the leading slash in the insert function.
Either that or always add one
good catch @whikloj. i'd sanitize input for consistency. it think i'd always remove it, since the base url is supposed to end with a slash.