apostrophecms / absolution Goto Github PK
View Code? Open in Web Editor NEWAccepts HTML and a base URL, and returns HTML with absolute URLs. Great for generating valid RSS feed entries.
Accepts HTML and a base URL, and returns HTML with absolute URLs. Great for generating valid RSS feed entries.
while trying to make a PR for #1 I noticed that you are looping over every element with htmlparser2
and then reconstructing the element. This depends on knowing exactly which elements are self-closing etc. It seems rather risky -- I would normally only do this for elements that actually have a url.
Is there a reason why it seems to be reconstructing elements that do not have urls too?
It would be great if the base url could also include a path
var absolution = require('absolution');
var dirty = '<a href="/foo">Foo!</a>';
var clean = absolution(dirty, 'http://example.com/path');
// expected
// clean is now:
// <a href="http://example.com/path/foo">Foo!</a>
// actual result
// clean is now:
// <a href="http://example.com/foo">Foo!</a>
This module's great! I use it to prepare content for my journal's syndication feeds.
My only complaint so far is that it doesn't appear to process the srcset
attribute:
<!-- Source markup: -->
<img src="cat.jpg" alt="cat"
srcset="cat-320.jpg 320w, cat-640.jpg 640w, cat-1280.jpg 1280w">
<!-- What I would expect: -->
<img src="http://example.com/cat.jpg" alt="cat"
srcset="http://example.com/cat-320.jpg 320w, http://example.com/cat-640.jpg 640w, http://example.com/cat-1280.jpg 1280w">
<!-- What happens instead: -->
<img src="http://example.com/cat.jpg" alt="cat"
srcset="cat-320.jpg 320w, cat-640.jpg 640w, cat-1280.jpg 1280w">
Luckily feed readers don't seem to care too much (it seems like they fall back to src
), but figured I'd create an issue 'cause sharing is caring. ๐
I believe this is a bug.
Absolution is sometimes a little bit too excited and can "absolutify" URLs that are non-existant, such as is the case here:
<html>
<head>
<link rel="stylesheet" href="" />
</head>
<body></body>
</html>
When used with absolution(html, 'http://localhost:8000/index.html')
it results in:
<html>
<head>
<link rel="stylesheet" href="http://localhost:8000/index.html" />
</head>
<body></body>
</html>
But it should stay the same, unless the original html specified href="."
Note that the expected behavior is also how absoluteify
works, though I cannot use that library due to another bug
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.