Closed sndsabin closed 4 years ago
fixRelativeUrls doesn't work as expected
fixRelativeUrls
fixRelativeUrls doesn't work as expected for the absolute path for some url https://example.com/test (in either case if provided by user or if present in <base>) :
https://example.com/test
<base>
<img class="svg" src="/images/example-logo.svg" alt="example-alt-text"/>
Expected: https://example.com/images/example-logo.svg
https://example.com/images/example-logo.svg
Returns: https://example.com/test/images/example-logo.svg
https://example.com/test/images/example-logo.svg
https://github.com/winhtaikaung/react-tiny-link/blob/93c25decb837bf687d266e50f33a24bed6b1c9c1/src/rules/utils.ts#L75
baseUrl defaults to user provided url if <base> is not present in DOM
baseUrl
Proposal: Instead default to origin of the user provided url. https://github.com/winhtaikaung/react-tiny-link/blob/93c25decb837bf687d266e50f33a24bed6b1c9c1/src/rules/Default/ScrapDefault.ts#L6
origin
fixRelativeUrls
doesn't work as expectedfixRelativeUrls
doesn't work as expected for the absolute path for some urlhttps://example.com/test
(in either case if provided by user or if present in<base>
) :<img class="svg" src="/images/example-logo.svg" alt="example-alt-text"/>
Expected:
https://example.com/images/example-logo.svg
Returns:
https://example.com/test/images/example-logo.svg
https://github.com/winhtaikaung/react-tiny-link/blob/93c25decb837bf687d266e50f33a24bed6b1c9c1/src/rules/utils.ts#L75
baseUrl
defaults to user provided url if<base>
is not present in DOMProposal: Instead default to
origin
of the user provided url. https://github.com/winhtaikaung/react-tiny-link/blob/93c25decb837bf687d266e50f33a24bed6b1c9c1/src/rules/Default/ScrapDefault.ts#L6