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

Render an absolute feed URL #143

Merged
merged 1 commit into from
Jun 1, 2020
Merged

Conversation

darekkay
Copy link
Contributor

This PR is an update to #29.

This supposed to be a small PR, but I've encountered some issues regarding the base URL.

The full_url_for function expects the config.url not to end with a forward slash. Otherwise it will create a double slash URL, e.g. http://example.com//atom.xml (notice that a double slash replacement happens only after the base URL).

I was wondering how the icon feature (#102) can be using full_url_for with the current code and not run into any double slash issues. The answer is: it doesn't handle this case. The unit tests are simply running against a custom base URL without an ending slash.

So I've cleaned up the tests:

  • removed the ending slash from the test base URL
  • adjusted and added new tests to handle subdirectories correctly (as specified in the hexo documentation)
  • hard-coded expected values - it makes a test more reliable and readable

All in all, the RSS code itself was and is correct as far as I can judge it, but the tests were faulty.

@coveralls
Copy link

coveralls commented May 26, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling a4d9bb6 on darekkay:feed-absolute-url into 866c21f on hexojs:master.

This PR is an update to hexojs#29.

This supposed to be a small PR, but I've encountered some issues regarding the base URL.

The `[full_url_for](https://github.com/hexojs/hexo-util/blob/master/lib/full_url_for.js#L27)` function expects the `config.url` not to end with a forward slash. Otherwise it will create a double slash URL, e.g. `http://example.com//atom.xml` (notice that a double slash replacement happens only _after_ the base URL).

I was wondering how the icon feature (hexojs#102) can be using `full_url_for` with the current code and not run into any double slash issues. The answer is: it doesn't handle this case. The [unit tests](https://github.com/hexojs/hexo-generator-feed/pull/102/files#diff-910eb6f57886ca16c136101fb1699231R240) are simply running against a custom base URL without an ending slash.

I've cleaned up the tests:
- removed the ending slash from the base URL
- adjusted and added new tests to handle subdirectories correctly (as specified in the [hexo documentation](https://hexo.io/docs/configuration.html#URL))
- hard-coded expected values - it makes a test more reliable and readable
Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

LGTM!

@SukkaW SukkaW requested a review from a team May 28, 2020 01:48
@SukkaW SukkaW merged commit c164383 into hexojs:master Jun 1, 2020
@darekkay darekkay deleted the feed-absolute-url branch June 1, 2020 07:01
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.

4 participants