-
-
Notifications
You must be signed in to change notification settings - Fork 88
Fix handling objects with relative URL #443
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
Conversation
|
The docs for this pull request have been published: |
|
The latest push to this pull request has been published to JSR and npm as a pre-release:
|
Remove unnecessary baseUrl storage from generated classes and streamline relative URL resolution to only occur during JSON-LD decoding. Changes: - Remove baseUrl property and getter from generated vocabulary classes - Remove baseUrl option from class constructors - Add explicit baseUrlVar parameter to scalar type decoder methods - Use optional chaining (options?.baseUrl) for safer URL resolution - Maintain relative URL support without storing baseUrl in instances This improves upon PR fedify-dev#443's approach by avoiding unnecessary property storage while still resolving relative URLs when baseUrl is provided during fromJsonLd() calls.
|
@sij411 I've made some refinements to your approach and added a new commit (85cf50d) to improve the baseUrl handling. I removed the unnecessary This approach is more efficient because classes don't carry around The changes are now pushed to your branch and should address the issue more elegantly while keeping the codebase clean. |
Summary
Handle relative url by adding baseUrl
Related Issue
Reference the related issue(s) by number, e.g.:
Changes
accept and store a
baseUrlparameter through theirfromJsonLd()method optionstype.tsto properly resolve relative URLs(like /media/image.jpg) by concatenating them with the provided baseUrl
TypeError: Invalid URL, the system nowgracefully handles relative URLs by either resolving them with a base URL or returning null when no
base URL is provided.
baseUrlgetter property allowingusers to access the stored base URL (e.g.
protected readonly _baseUrl?: URL)system to support the
new baseUrl?: URLparameterinstead of being rejected.
"http://www.w3.org/2001/XMLSchema#anyURI", "fedify:url"intype.tsBenefits
encountering relative URLs from ActivityPub servers, significantly improving
fediverse interoperability
instead of throwing errors, allowing applications to handle missing data
appropriately
unchanged while adding new functionality through the public baseUrl property
getter
Checklist
deno task test-allon your machine?Additional Notes
property.tsso it still returnsInvalid URLissue if user use.fromJsonLd()withoutbaseUrl