bazicalculator-url-tools 0.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +20 -0
- data/ruby/lib/bazicalculator_url_tools.rb +65 -0
- metadata +47 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f7e88d621c91b438abbcd1127913237e26eade275526df8b5fc095bdd8a8ae1d
|
|
4
|
+
data.tar.gz: a86dd364a7ee3dc1db23f8e403b6f92726b43a7332229af9503393002324c576
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0ecd1d2037530013c21412eab1536b61ea274d4bc88ec2aca92b260d313493f3bf421aec998c59995c97ce8d5bfb58af93e694e36ad9202f2892c75949d36561
|
|
7
|
+
data.tar.gz: 1df71f4a3af01529f575f2a915d6dc2faa8458b14f69b70ef29ae7175b30ffdf12c7037ececf98ae5f48b5060111f2d159dcedadbc7ba3ba77adc816c5efe11b
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wangneo276-lgtm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# bazicalculator-url-tools
|
|
2
|
+
|
|
3
|
+
Builds canonical HTTPS URLs for public pages on [BaZi Calculator](https://bazicalculator.pro/).
|
|
4
|
+
|
|
5
|
+
Free BaZi calculator: Four Pillars, Day Master, Ten Gods, Five Elements and Luck Pillars with true solar time. Plus Zi Wei Dou Shu, Liu Yao, Mei Hua, Qi Men and the Chinese Almanac.
|
|
6
|
+
|
|
7
|
+
Not an official SDK. The helper only accepts paths that are already on the public site, including English and the Chinese (`/zh`) translations. Privacy, terms, refund, and email support stay English-only. It does not calculate a chart or call the site.
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
- `homeUrl()` → https://bazicalculator.pro/
|
|
12
|
+
- `pageUrl("about")` → https://bazicalculator.pro/about
|
|
13
|
+
- `localeUrl("zh", "about")` → https://bazicalculator.pro/zh/about
|
|
14
|
+
- `blogUrl("bazi-compatibility-basics")` → https://bazicalculator.pro/blog/bazi-compatibility-basics
|
|
15
|
+
|
|
16
|
+
Support: support@bazicalculator.pro
|
|
17
|
+
|
|
18
|
+
Source: https://github.com/wangneo276-lgtm/bazicalculator-url-tools
|
|
19
|
+
|
|
20
|
+
License: MIT.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module BazicalculatorUrlTools
|
|
2
|
+
ORIGIN = 'https://bazicalculator.pro'.freeze
|
|
3
|
+
DESCRIPTION = 'Free BaZi calculator: Four Pillars, Day Master, Ten Gods, Five Elements and Luck Pillars with true solar time. Plus Zi Wei Dou Shu, Liu Yao, Mei Hua, Qi Men and the Chinese Almanac.'.freeze
|
|
4
|
+
HOST = 'bazicalculator.pro'.freeze
|
|
5
|
+
PATHS = ['/', '/about', '/blog', '/blog/bazi-compatibility-basics', '/blog/category/bazi', '/blog/category/bazi/page/2', '/blog/category/bazi/page/3', '/blog/category/method', '/blog/category/tools', '/blog/chinese-almanac-yi-ji', '/blog/combinations-and-clashes-in-bazi', '/blog/companions-friend-and-rob-wealth', '/blog/day-master', '/blog/day-master-strength', '/blog/daylight-saving-and-bazi', '/blog/earthly-branches-and-hidden-stems', '/blog/five-elements-in-bazi', '/blog/heavenly-stems-explained', '/blog/li-chun-and-the-bazi-year', '/blog/liu-yao-coin-method', '/blog/luck-pillars', '/blog/mei-hua-yi-shu-time-casting', '/blog/page/2', '/blog/page/3', '/blog/page/4', '/blog/page/5', '/blog/pillar-positions-in-bazi', '/blog/qi-men-dun-jia-basics', '/blog/reading-annual-pillars', '/blog/solar-terms-and-bazi-months', '/blog/ten-gods', '/blog/ten-gods-output-and-resource', '/blog/ten-gods-wealth-and-officer', '/blog/true-solar-time', '/blog/twelve-growth-stages', '/blog/unknown-birth-time-bazi', '/blog/useful-element-yong-shen', '/blog/what-is-bazi', '/blog/zi-hour-day-boundary', '/blog/zi-wei-dou-shu-basics', '/changelog', '/chinese-almanac', '/compare', '/compare/bazi-vs-western-astrology', '/compare/bazi-vs-zi-wei-dou-shu', '/compare/liu-yao-vs-mei-hua', '/compare/qi-men-vs-liu-yao', '/compare/true-solar-time-vs-clock-time', '/compare/zi-hour-23-vs-00', '/compatibility', '/compatibility/earth-and-earth', '/compatibility/earth-and-metal', '/compatibility/earth-and-water', '/compatibility/fire-and-earth', '/compatibility/fire-and-fire', '/compatibility/fire-and-metal', '/compatibility/fire-and-water', '/compatibility/metal-and-metal', '/compatibility/metal-and-water', '/compatibility/water-and-water', '/compatibility/wood-and-earth', '/compatibility/wood-and-fire', '/compatibility/wood-and-metal', '/compatibility/wood-and-water', '/compatibility/wood-and-wood', '/day-master', '/day-master/bing-fire', '/day-master/ding-fire', '/day-master/geng-metal', '/day-master/gui-water', '/day-master/ji-earth', '/day-master/jia-wood', '/day-master/ren-water', '/day-master/wu-earth', '/day-master/xin-metal', '/day-master/yi-wood', '/earthly-branches', '/earthly-branches/chen', '/earthly-branches/chou', '/earthly-branches/hai', '/earthly-branches/mao', '/earthly-branches/shen', '/earthly-branches/si', '/earthly-branches/wei', '/earthly-branches/wu', '/earthly-branches/xu', '/earthly-branches/yin', '/earthly-branches/you', '/earthly-branches/zi', '/email-support', '/faq', '/faq/bazi', '/faq/chinese-almanac', '/faq/liu-yao', '/faq/mei-hua-yi-shu', '/faq/qi-men-dun-jia', '/faq/zi-wei-dou-shu', '/five-elements', '/five-elements/earth', '/five-elements/earth-strong', '/five-elements/earth-weak', '/five-elements/fire', '/five-elements/fire-strong', '/five-elements/fire-weak', '/five-elements/metal', '/five-elements/metal-strong', '/five-elements/metal-weak', '/five-elements/water', '/five-elements/water-strong', '/five-elements/water-weak', '/five-elements/wood', '/five-elements/wood-strong', '/five-elements/wood-weak', '/glossary', '/glossary/annual-pillar', '/glossary/body-and-use', '/glossary/branch-clash', '/glossary/branch-harm', '/glossary/branch-punishment', '/glossary/changing-line', '/glossary/chart-structure', '/glossary/chinese-new-year-vs-li-chun', '/glossary/controlling-cycle', '/glossary/day-master', '/glossary/day-pillar', '/glossary/directional-combination', '/glossary/earthly-branches', '/glossary/favorable-element', '/glossary/five-elements', '/glossary/follower-chart', '/glossary/four-pillars', '/glossary/generating-cycle', '/glossary/heavenly-stems', '/glossary/hexagram', '/glossary/hidden-stems', '/glossary/hour-pillar', '/glossary/luck-direction-term', '/glossary/luck-pillars', '/glossary/month-pillar', '/glossary/na-jia', '/glossary/na-yin', '/glossary/nine-palaces', '/glossary/nobleman-star', '/glossary/peach-blossom', '/glossary/root', '/glossary/seasonal-strength', '/glossary/sexagenary-cycle', '/glossary/six-combinations', '/glossary/solar-terms', '/glossary/start-of-spring', '/glossary/starting-age', '/glossary/stem-clash', '/glossary/stem-combination', '/glossary/strong-day-master', '/glossary/ten-gods', '/glossary/three-harmony', '/glossary/travelling-horse', '/glossary/trigram', '/glossary/true-solar-time', '/glossary/twelve-growth-stages', '/glossary/unfavorable-element', '/glossary/useful-element', '/glossary/void-emptiness', '/glossary/weak-day-master', '/glossary/year-pillar', '/glossary/yin-yang', '/glossary/zi-hour', '/heavenly-stems', '/heavenly-stems/bing', '/heavenly-stems/ding', '/heavenly-stems/geng', '/heavenly-stems/gui', '/heavenly-stems/ji', '/heavenly-stems/jia', '/heavenly-stems/ren', '/heavenly-stems/wu', '/heavenly-stems/xin', '/heavenly-stems/yi', '/learn', '/learn/check-your-bazi-chart', '/learn/combinations-and-clashes', '/learn/find-the-useful-element', '/learn/find-your-day-master', '/learn/four-pillars-of-destiny', '/learn/how-to-read-a-bazi-chart', '/learn/judge-day-master-strength', '/learn/read-luck-pillars-step-by-step', '/learn/read-ten-gods-in-context', '/learn/unknown-birth-time', '/liu-yao', '/luck-pillars', '/luck-pillars/annual-pillar', '/luck-pillars/changing-luck-pillars', '/luck-pillars/how-to-read-a-luck-pillar', '/luck-pillars/luck-and-natal-interactions', '/luck-pillars/luck-direction', '/luck-pillars/starting-age', '/mei-hua-yi-shu', '/methodology', '/pricing', '/privacy-policy', '/qi-men-dun-jia', '/refund-policy', '/ten-gods', '/ten-gods/direct-officer', '/ten-gods/direct-resource', '/ten-gods/direct-wealth', '/ten-gods/eating-god', '/ten-gods/friend', '/ten-gods/hurting-officer', '/ten-gods/indirect-resource', '/ten-gods/indirect-wealth', '/ten-gods/rob-wealth', '/ten-gods/seven-killings', '/terms-of-service', '/tools', '/tools/annual-pillar-calculator', '/tools/bazi-compatibility-calculator', '/tools/chinese-calendar-converter', '/tools/day-master-calculator', '/tools/five-elements-calculator', '/tools/hidden-stems-calculator', '/tools/luck-pillar-calculator', '/tools/ten-gods-calculator', '/tools/true-solar-time-calculator', '/zh', '/zh/about', '/zh/blog', '/zh/blog/bazi-compatibility-basics', '/zh/blog/category/bazi', '/zh/blog/category/bazi/page/2', '/zh/blog/category/bazi/page/3', '/zh/blog/category/method', '/zh/blog/category/tools', '/zh/blog/chinese-almanac-yi-ji', '/zh/blog/combinations-and-clashes-in-bazi', '/zh/blog/companions-friend-and-rob-wealth', '/zh/blog/day-master', '/zh/blog/day-master-strength', '/zh/blog/daylight-saving-and-bazi', '/zh/blog/earthly-branches-and-hidden-stems', '/zh/blog/five-elements-in-bazi', '/zh/blog/heavenly-stems-explained', '/zh/blog/li-chun-and-the-bazi-year', '/zh/blog/liu-yao-coin-method', '/zh/blog/luck-pillars', '/zh/blog/mei-hua-yi-shu-time-casting', '/zh/blog/page/2', '/zh/blog/page/3', '/zh/blog/page/4', '/zh/blog/page/5', '/zh/blog/pillar-positions-in-bazi', '/zh/blog/qi-men-dun-jia-basics', '/zh/blog/reading-annual-pillars', '/zh/blog/solar-terms-and-bazi-months', '/zh/blog/ten-gods', '/zh/blog/ten-gods-output-and-resource', '/zh/blog/ten-gods-wealth-and-officer', '/zh/blog/true-solar-time', '/zh/blog/twelve-growth-stages', '/zh/blog/unknown-birth-time-bazi', '/zh/blog/useful-element-yong-shen', '/zh/blog/what-is-bazi', '/zh/blog/zi-hour-day-boundary', '/zh/blog/zi-wei-dou-shu-basics', '/zh/changelog', '/zh/chinese-almanac', '/zh/compare', '/zh/compare/bazi-vs-western-astrology', '/zh/compare/bazi-vs-zi-wei-dou-shu', '/zh/compare/liu-yao-vs-mei-hua', '/zh/compare/qi-men-vs-liu-yao', '/zh/compare/true-solar-time-vs-clock-time', '/zh/compare/zi-hour-23-vs-00', '/zh/compatibility', '/zh/compatibility/earth-and-earth', '/zh/compatibility/earth-and-metal', '/zh/compatibility/earth-and-water', '/zh/compatibility/fire-and-earth', '/zh/compatibility/fire-and-fire', '/zh/compatibility/fire-and-metal', '/zh/compatibility/fire-and-water', '/zh/compatibility/metal-and-metal', '/zh/compatibility/metal-and-water', '/zh/compatibility/water-and-water', '/zh/compatibility/wood-and-earth', '/zh/compatibility/wood-and-fire', '/zh/compatibility/wood-and-metal', '/zh/compatibility/wood-and-water', '/zh/compatibility/wood-and-wood', '/zh/day-master', '/zh/day-master/bing-fire', '/zh/day-master/ding-fire', '/zh/day-master/geng-metal', '/zh/day-master/gui-water', '/zh/day-master/ji-earth', '/zh/day-master/jia-wood', '/zh/day-master/ren-water', '/zh/day-master/wu-earth', '/zh/day-master/xin-metal', '/zh/day-master/yi-wood', '/zh/earthly-branches', '/zh/earthly-branches/chen', '/zh/earthly-branches/chou', '/zh/earthly-branches/hai', '/zh/earthly-branches/mao', '/zh/earthly-branches/shen', '/zh/earthly-branches/si', '/zh/earthly-branches/wei', '/zh/earthly-branches/wu', '/zh/earthly-branches/xu', '/zh/earthly-branches/yin', '/zh/earthly-branches/you', '/zh/earthly-branches/zi', '/zh/faq', '/zh/faq/bazi', '/zh/faq/chinese-almanac', '/zh/faq/liu-yao', '/zh/faq/mei-hua-yi-shu', '/zh/faq/qi-men-dun-jia', '/zh/faq/zi-wei-dou-shu', '/zh/five-elements', '/zh/five-elements/earth', '/zh/five-elements/earth-strong', '/zh/five-elements/earth-weak', '/zh/five-elements/fire', '/zh/five-elements/fire-strong', '/zh/five-elements/fire-weak', '/zh/five-elements/metal', '/zh/five-elements/metal-strong', '/zh/five-elements/metal-weak', '/zh/five-elements/water', '/zh/five-elements/water-strong', '/zh/five-elements/water-weak', '/zh/five-elements/wood', '/zh/five-elements/wood-strong', '/zh/five-elements/wood-weak', '/zh/glossary', '/zh/glossary/annual-pillar', '/zh/glossary/body-and-use', '/zh/glossary/branch-clash', '/zh/glossary/branch-harm', '/zh/glossary/branch-punishment', '/zh/glossary/changing-line', '/zh/glossary/chart-structure', '/zh/glossary/chinese-new-year-vs-li-chun', '/zh/glossary/controlling-cycle', '/zh/glossary/day-master', '/zh/glossary/day-pillar', '/zh/glossary/directional-combination', '/zh/glossary/earthly-branches', '/zh/glossary/favorable-element', '/zh/glossary/five-elements', '/zh/glossary/follower-chart', '/zh/glossary/four-pillars', '/zh/glossary/generating-cycle', '/zh/glossary/heavenly-stems', '/zh/glossary/hexagram', '/zh/glossary/hidden-stems', '/zh/glossary/hour-pillar', '/zh/glossary/luck-direction-term', '/zh/glossary/luck-pillars', '/zh/glossary/month-pillar', '/zh/glossary/na-jia', '/zh/glossary/na-yin', '/zh/glossary/nine-palaces', '/zh/glossary/nobleman-star', '/zh/glossary/peach-blossom', '/zh/glossary/root', '/zh/glossary/seasonal-strength', '/zh/glossary/sexagenary-cycle', '/zh/glossary/six-combinations', '/zh/glossary/solar-terms', '/zh/glossary/start-of-spring', '/zh/glossary/starting-age', '/zh/glossary/stem-clash', '/zh/glossary/stem-combination', '/zh/glossary/strong-day-master', '/zh/glossary/ten-gods', '/zh/glossary/three-harmony', '/zh/glossary/travelling-horse', '/zh/glossary/trigram', '/zh/glossary/true-solar-time', '/zh/glossary/twelve-growth-stages', '/zh/glossary/unfavorable-element', '/zh/glossary/useful-element', '/zh/glossary/void-emptiness', '/zh/glossary/weak-day-master', '/zh/glossary/year-pillar', '/zh/glossary/yin-yang', '/zh/glossary/zi-hour', '/zh/heavenly-stems', '/zh/heavenly-stems/bing', '/zh/heavenly-stems/ding', '/zh/heavenly-stems/geng', '/zh/heavenly-stems/gui', '/zh/heavenly-stems/ji', '/zh/heavenly-stems/jia', '/zh/heavenly-stems/ren', '/zh/heavenly-stems/wu', '/zh/heavenly-stems/xin', '/zh/heavenly-stems/yi', '/zh/learn', '/zh/learn/check-your-bazi-chart', '/zh/learn/combinations-and-clashes', '/zh/learn/find-the-useful-element', '/zh/learn/find-your-day-master', '/zh/learn/four-pillars-of-destiny', '/zh/learn/how-to-read-a-bazi-chart', '/zh/learn/judge-day-master-strength', '/zh/learn/read-luck-pillars-step-by-step', '/zh/learn/read-ten-gods-in-context', '/zh/learn/unknown-birth-time', '/zh/liu-yao', '/zh/luck-pillars', '/zh/luck-pillars/annual-pillar', '/zh/luck-pillars/changing-luck-pillars', '/zh/luck-pillars/how-to-read-a-luck-pillar', '/zh/luck-pillars/luck-and-natal-interactions', '/zh/luck-pillars/luck-direction', '/zh/luck-pillars/starting-age', '/zh/mei-hua-yi-shu', '/zh/methodology', '/zh/pricing', '/zh/qi-men-dun-jia', '/zh/ten-gods', '/zh/ten-gods/direct-officer', '/zh/ten-gods/direct-resource', '/zh/ten-gods/direct-wealth', '/zh/ten-gods/eating-god', '/zh/ten-gods/friend', '/zh/ten-gods/hurting-officer', '/zh/ten-gods/indirect-resource', '/zh/ten-gods/indirect-wealth', '/zh/ten-gods/rob-wealth', '/zh/ten-gods/seven-killings', '/zh/tools', '/zh/tools/annual-pillar-calculator', '/zh/tools/bazi-compatibility-calculator', '/zh/tools/chinese-calendar-converter', '/zh/tools/day-master-calculator', '/zh/tools/five-elements-calculator', '/zh/tools/hidden-stems-calculator', '/zh/tools/luck-pillar-calculator', '/zh/tools/ten-gods-calculator', '/zh/tools/true-solar-time-calculator', '/zh/zi-wei-dou-shu-calculator', '/zi-wei-dou-shu-calculator'].freeze
|
|
6
|
+
ENGLISH_ONLY = ['/email-support', '/privacy-policy', '/refund-policy', '/terms-of-service'].freeze
|
|
7
|
+
PAGES = {'about' => '/about', 'changelog' => '/changelog', 'chinese-almanac' => '/chinese-almanac', 'compare' => '/compare', 'compatibility' => '/compatibility', 'day-master' => '/day-master', 'earthly-branches' => '/earthly-branches', 'faq' => '/faq', 'five-elements' => '/five-elements', 'glossary' => '/glossary', 'heavenly-stems' => '/heavenly-stems', 'home' => '/', 'learn' => '/learn', 'liu-yao' => '/liu-yao', 'luck-pillars' => '/luck-pillars', 'mei-hua-yi-shu' => '/mei-hua-yi-shu', 'methodology' => '/methodology', 'pricing' => '/pricing', 'qi-men-dun-jia' => '/qi-men-dun-jia', 'ten-gods' => '/ten-gods', 'tools' => '/tools', 'zi-wei-dou-shu-calculator' => '/zi-wei-dou-shu-calculator'}.freeze
|
|
8
|
+
BLOGS = {'bazi-compatibility-basics' => '/blog/bazi-compatibility-basics', 'chinese-almanac-yi-ji' => '/blog/chinese-almanac-yi-ji', 'combinations-and-clashes-in-bazi' => '/blog/combinations-and-clashes-in-bazi', 'companions-friend-and-rob-wealth' => '/blog/companions-friend-and-rob-wealth', 'day-master' => '/blog/day-master', 'day-master-strength' => '/blog/day-master-strength', 'daylight-saving-and-bazi' => '/blog/daylight-saving-and-bazi', 'earthly-branches-and-hidden-stems' => '/blog/earthly-branches-and-hidden-stems', 'five-elements-in-bazi' => '/blog/five-elements-in-bazi', 'heavenly-stems-explained' => '/blog/heavenly-stems-explained', 'li-chun-and-the-bazi-year' => '/blog/li-chun-and-the-bazi-year', 'liu-yao-coin-method' => '/blog/liu-yao-coin-method', 'luck-pillars' => '/blog/luck-pillars', 'mei-hua-yi-shu-time-casting' => '/blog/mei-hua-yi-shu-time-casting', 'pillar-positions-in-bazi' => '/blog/pillar-positions-in-bazi', 'qi-men-dun-jia-basics' => '/blog/qi-men-dun-jia-basics', 'reading-annual-pillars' => '/blog/reading-annual-pillars', 'solar-terms-and-bazi-months' => '/blog/solar-terms-and-bazi-months', 'ten-gods' => '/blog/ten-gods', 'ten-gods-output-and-resource' => '/blog/ten-gods-output-and-resource', 'ten-gods-wealth-and-officer' => '/blog/ten-gods-wealth-and-officer', 'true-solar-time' => '/blog/true-solar-time', 'twelve-growth-stages' => '/blog/twelve-growth-stages', 'unknown-birth-time-bazi' => '/blog/unknown-birth-time-bazi', 'useful-element-yong-shen' => '/blog/useful-element-yong-shen', 'what-is-bazi' => '/blog/what-is-bazi', 'zi-hour-day-boundary' => '/blog/zi-hour-day-boundary', 'zi-wei-dou-shu-basics' => '/blog/zi-wei-dou-shu-basics'}.freeze
|
|
9
|
+
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def canonical_url(input)
|
|
13
|
+
raise ArgumentError, 'path required' unless input.is_a?(String)
|
|
14
|
+
raw = input.strip
|
|
15
|
+
raise ArgumentError, 'path required' if raw.empty?
|
|
16
|
+
raise ArgumentError, 'invalid path' if raw.include?('\\') || raw.include?('%')
|
|
17
|
+
raw = raw.split('#', 2)[0].split('?', 2)[0]
|
|
18
|
+
lower = raw.downcase
|
|
19
|
+
if lower.start_with?('https://') || lower.start_with?('http://') || raw.start_with?('//')
|
|
20
|
+
rest = if lower.start_with?('https://')
|
|
21
|
+
raw.delete_prefix('https://')
|
|
22
|
+
elsif lower.start_with?('http://')
|
|
23
|
+
raw.delete_prefix('http://')
|
|
24
|
+
else
|
|
25
|
+
raw.delete_prefix('//')
|
|
26
|
+
end
|
|
27
|
+
slash = rest.index('/')
|
|
28
|
+
hostport = slash ? rest[0...slash] : rest
|
|
29
|
+
path = slash ? rest[slash..] : '/'
|
|
30
|
+
raise ArgumentError, 'host not allowed' if hostport.include?('@') || hostport.include?(':') || hostport.downcase != HOST
|
|
31
|
+
elsif raw.start_with?('/')
|
|
32
|
+
path = raw
|
|
33
|
+
else
|
|
34
|
+
path = '/' + raw
|
|
35
|
+
end
|
|
36
|
+
path = path.downcase.gsub(%r{//+}, '/')
|
|
37
|
+
path = path.sub(%r{/+\z}, '') if path.length > 1
|
|
38
|
+
path = '/' if path.empty?
|
|
39
|
+
raise ArgumentError, 'unknown path' unless PATHS.include?(path)
|
|
40
|
+
path == '/' ? ORIGIN + '/' : ORIGIN + path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def home_url
|
|
44
|
+
canonical_url('/')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def page_url(key)
|
|
48
|
+
path = PAGES[key] or raise ArgumentError, 'unknown page'
|
|
49
|
+
canonical_url(path)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def blog_url(slug)
|
|
53
|
+
path = BLOGS[slug] or raise ArgumentError, 'unknown blog'
|
|
54
|
+
canonical_url(path)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def locale_url(locale, key)
|
|
58
|
+
raise ArgumentError, 'locale not available' unless %w[en zh].include?(locale)
|
|
59
|
+
path = PAGES[key] or raise ArgumentError, 'unknown page'
|
|
60
|
+
raise ArgumentError, 'locale not available' if locale == 'zh' && ENGLISH_ONLY.include?(path)
|
|
61
|
+
return canonical_url(path) if locale == 'en'
|
|
62
|
+
prefixed = path == '/' ? '/zh' : '/zh' + path
|
|
63
|
+
canonical_url(prefixed)
|
|
64
|
+
end
|
|
65
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bazicalculator-url-tools
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- wangneo276-lgtm
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: 'Free BaZi calculator: Four Pillars, Day Master, Ten Gods, Five Elements
|
|
13
|
+
and Luck Pillars with true solar time. Plus Zi Wei Dou Shu, Liu Yao, Mei Hua, Qi
|
|
14
|
+
Men and the Chinese Almanac.'
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE
|
|
20
|
+
- README.md
|
|
21
|
+
- ruby/lib/bazicalculator_url_tools.rb
|
|
22
|
+
homepage: https://bazicalculator.pro/
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata:
|
|
26
|
+
homepage_uri: https://bazicalculator.pro/
|
|
27
|
+
source_code_uri: https://github.com/wangneo276-lgtm/bazicalculator-url-tools
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- ruby/lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '3.0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 4.0.11
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: 'Free BaZi calculator: Four Pillars, Day Master, Ten Gods, Five Elements
|
|
45
|
+
and Luck Pillars with true solar time. Plus Zi Wei Dou Shu, Liu Yao, Mei Hua, Qi
|
|
46
|
+
Men and the Chinese Almanac.'
|
|
47
|
+
test_files: []
|