Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE and add isDirectory check in slurp #669

Merged
merged 1 commit into from
Mar 3, 2020

Conversation

Cartmanishere
Copy link
Contributor

Fix some issues in slurp middleware as seen in #534

@@ -26,3 +26,10 @@
(t/is (= ["application/octet-stream" {}] (:content-type resp)))
(t/is (str/starts-with? (:body resp) "#binary[location="))
(t/is (str/ends-with? (:body resp) ",size=681]"))))

(t/deftest test-directory
Copy link
Member

Choose a reason for hiding this comment

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

Don't we also need for whatever was causing the NPE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem was some URLs return nil when doing .getContentType. I couldn't really figure out why the URLs did not return a content type.
I thought it was because of redirection but not all redirected URLs return nil. Tried various HTTP return codes. No idea why this happens.

@@ -43,7 +43,8 @@
`[type {:as attrs}]`. This method normalizes RFC
compliant content-types to this form."
[^String content-type]
(if-let [match (re-find content-type-pattern content-type)]
(if-let [match (and content-type
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this nil check be handled in the caller of normalize-content-type? I think it's weird to expect to receive a nil argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Makes sense.

@bbatsov
Copy link
Member

bbatsov commented Mar 1, 2020

Thanks for tackling this! I've left some small remarks. Don't forget to add a changelog entry as well.

@bbatsov bbatsov merged commit 6f6e73b into clojure-emacs:master Mar 3, 2020
@bbatsov
Copy link
Member

bbatsov commented Mar 3, 2020

Thanks for tackling this! 🙇

@Cartmanishere Cartmanishere deleted the slurp-fix branch March 3, 2020 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants