You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
Links 404 because link does not include subproject directory path provided in repository.directory of package.json
Steps to Reproduce
Add a relative link to README.md of a package in a subdirectory of a monorepo and publish that package.
Expected Behavior
Relative links become fully qualified URLs to github subproject resource in monrepo.
Who
n/a
The Fix
First the consumer of marky-markdown must be passed a package.json meta-data including the repository.directory, I could not find the source code for npmjs.org but I assume this is not the case today because lib/plugin/github.js treats package.repository as a string type, which does not match the example in the README.md.
- var repo = gh(opts.package.repository)+ // Handling both `string` and `{ url: string }` types+ var repo = gh(opts.package.repository.url | opt.package.repository)
Next buildLinkUrl should use opt.package.repository.directory when building the fully qualified path:
- return prefix + path.join(repository.user, repository.repo, DEFAULT_REF, url.href)+ // Just an example, `opt` is not in scope, refactor to pass in the repository directory,+ return prefix + path.join(repository.user, repository.repo, DEFAULT_REF, opt.package.repository.directory, url.href)
There is an open bug npm/marky-markdown#449 which suggests this workaround.
On top of that I changed the package.json to represent that we are here in a monorepo
What / Why
The problem is described well in the following NPM community post and PR
The
package.respository.directory
is not honored when generating URLs for relative paths in README.mds of NPM packages displayed on npmjs.org.How
When
Where
npmjs.org package pages for example, any link on https://www.npmjs.com/package/hint/v/6.0.1#further-reading
Current Behavior
Links 404 because link does not include subproject directory path provided in
repository.directory
ofpackage.json
Steps to Reproduce
Add a relative link to README.md of a package in a subdirectory of a monorepo and publish that package.
Expected Behavior
Relative links become fully qualified URLs to github subproject resource in monrepo.
Who
The Fix
First the consumer of
marky-markdown
must be passed apackage.json
meta-data including therepository.directory
, I could not find the source code for npmjs.org but I assume this is not the case today becauselib/plugin/github.js
treatspackage.repository
as astring
type, which does not match the example in the README.md.https://github.com/npm/marky-markdown/blob/master/lib/plugin/github.js#L52
Next
buildLinkUrl
should useopt.package.repository.directory
when building the fully qualified path:https://github.com/npm/marky-markdown/blob/master/lib/plugin/github.js#L12
References
Related to #435
Related to #446
The text was updated successfully, but these errors were encountered: