tailwind-hyperclay 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/index.js +10 -3
- package/package.json +1 -1
- package/test/test.js +6 -6
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -129,12 +129,18 @@ function extractCandidates(html) {
|
|
|
129
129
|
|
|
130
130
|
function getTailwindName(urlString) {
|
|
131
131
|
// Match relative path: /tailwindcss/name.css
|
|
132
|
-
// Or full URL: https://
|
|
132
|
+
// Or full URL with any domain: https://example.com/tailwindcss/name.css
|
|
133
133
|
// With optional query params (?v=123) or fragments (#section)
|
|
134
|
-
const match = urlString.match(/^(?:https
|
|
134
|
+
const match = urlString.match(/^(?:https?:\/\/[^/]+)?\/tailwindcss\/([^?#]+)\.css(?:[?#].*)?$/);
|
|
135
135
|
return match ? match[1] : null;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
function getTailwindPrefix(urlString) {
|
|
139
|
+
// Extract the domain prefix (e.g. "https://hyperclay.com") or empty string for relative URLs
|
|
140
|
+
const match = urlString.match(/^(https?:\/\/[^/]+)?\/tailwindcss\//);
|
|
141
|
+
return match?.[1] || '';
|
|
142
|
+
}
|
|
143
|
+
|
|
138
144
|
function extractHrefs(html) {
|
|
139
145
|
const hrefs = [];
|
|
140
146
|
const regex = /href\s*=\s*["']([^"']+)["']/gi;
|
|
@@ -163,7 +169,8 @@ function replaceTailwindLink(html, newName, sitePath) {
|
|
|
163
169
|
/(href\s*=\s*["'])([^"']+)(["'])/gi,
|
|
164
170
|
(match, prefix, url, suffix) => {
|
|
165
171
|
if (getTailwindName(url) !== null) {
|
|
166
|
-
|
|
172
|
+
const domainPrefix = getTailwindPrefix(url);
|
|
173
|
+
return `${prefix}${domainPrefix}/tailwindcss/${scopedName}.css${suffix}`;
|
|
167
174
|
}
|
|
168
175
|
return match;
|
|
169
176
|
}
|
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { compileTailwind,
|
|
1
|
+
const { compileTailwind, hasAnyTailwindLink, replaceTailwindLink, getTailwindCssName } = require('../index.js');
|
|
2
2
|
|
|
3
3
|
const testHTML = `
|
|
4
4
|
<!DOCTYPE html>
|
|
@@ -42,11 +42,11 @@ function test(name, actual, expected) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async function runTests() {
|
|
45
|
-
console.log('Testing
|
|
46
|
-
test('myApp found',
|
|
47
|
-
test('
|
|
48
|
-
test('myApp with
|
|
49
|
-
test('
|
|
45
|
+
console.log('Testing getTailwindCssName...');
|
|
46
|
+
test('myApp found', getTailwindCssName(testHTML), 'myApp');
|
|
47
|
+
test('myApp with query params', getTailwindCssName(testHTMLWithQueryParams), 'myApp');
|
|
48
|
+
test('myApp with fragment', getTailwindCssName(testHTMLWithFragment), 'myApp');
|
|
49
|
+
test('no link returns null', getTailwindCssName('<html></html>'), null);
|
|
50
50
|
|
|
51
51
|
console.log('\nTesting hasAnyTailwindLink...');
|
|
52
52
|
test('finds link', hasAnyTailwindLink(testHTML), true);
|