Skip to content

Fix handling/url-encoding of container names - #469

Merged
dmitrizagidulin merged 3 commits into
masterfrom
dz_fix_url_container_names
Dec 7, 2016
Merged

dmitrizagidulin merged 3 commits into
masterfrom
dz_fix_url_container_names

Conversation

@dmitrizagidulin

Copy link
Copy Markdown
Contributor

Fixes issue #422.

Currently, if you POST to / with a slug of http://csarven.ca/foo (to create a directory with that name), it succeeds with a response Location header of /http%3A%2F%2Fcsarven.ca%2Ffoo.
But what is physically created on the system is directory http: with subdirectory csarven.ca with file foo. Even if you uri-encode the slug before POSTing, the same thing happens, because the current behavior is to url-decode the slug for some reason, on the server.

The fixed behavior is now:

      let containerName = 'https://example.com/page'
      let expectedDirName = '/post-tests/https%3A%2F%2Fexample.com%2Fpage/'
      server.post('/post-tests/')
        .set('slug', containerName)
        .set('content-type', 'text/turtle')
        .set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
        .expect(201)
      // Now response.headers.location === expectedDirName, and that directory is created.

Similarly, retrieval of the created container works:

      let containerUrl = '/post-tests/https%3A%2F%2Fexample.com%2Fpage/'
      server.get(containerUrl)
        .expect('content-type', /text\/turtle/)
        .expect(200, done)

@dmitrizagidulin

Copy link
Copy Markdown
Contributor Author

Tagging @dan-f / @nicola for review.

@nicola nicola left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good with me

Comment thread test/http.js
})
})

it('should be able to access new url-named container', (done) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not clean up after every single test? I would have expected these two tests to be the same test, and for the resource /post-tests/https%3A%2F%2Fexample.com%2Fpage/ not to exist in the scope of other tests in this describe block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we clean up after each describe() block.

@dmitrizagidulin

Copy link
Copy Markdown
Contributor Author

Heads up, @csarven - PR #471 is going to change the policy of URLs as container names, when it gets merged. New procedure: uri-encode the Slug header before creating your inbox container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants