normalmapai-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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 15e6bdeb7a680b598346d9760229e2fe3f67f165832648af14c9946017ca4c22
4
+ data.tar.gz: 9d59b5608e977f27ee832e4a558fb3ca83768e8fe7405ae6b0b70c123d76eede
5
+ SHA512:
6
+ metadata.gz: bcfbd24f4fb26ee0ab0c6c7f53af2c23ae5c1b0669f72b4ade43cefb0d8d91902486023a51d64093f78fbe3a78f48d7ced497b09e4bee9a8ccd40756f8a44ee1
7
+ data.tar.gz: 1e065abc3a790750b99fe67d5ea7fcd00e759ef48ab5eef51e6f25ab11271b18a274e44a3ede3b67bb70fbcff1d0191fb07764ab1fbf8c10101248fd77c12dea
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
+ # normalmapai-url-tools
2
+
3
+ Builds canonical HTTPS URLs for pages that exist on [NormalMapAI](https://normalmapai.com/).
4
+
5
+ Free normal map generator by NormalMapAI. Convert any photo into a normal map with live 3D preview — plus height, roughness, AO and more. Private in-browser; export for Unity, Unreal, Godot and Blender.
6
+
7
+ Not an official SDK. The helper only accepts paths that are already on the public site. It does not upload images or call the site.
8
+
9
+ ## Examples
10
+
11
+ - `canonicalUrl("/height-map-generator/")` → https://normalmapai.com/height-map-generator
12
+ - `canonicalUrl("https://normalmapai.com/app?ref=1#editor")` → https://normalmapai.com/app
13
+ - `mapUrl("roughness")` → https://normalmapai.com/roughness-map-generator
14
+ - `mapUrl("ao")` → https://normalmapai.com/ao-map-generator
15
+ - `guideUrl("directx-vs-opengl-normal-maps")` → https://normalmapai.com/guides/directx-vs-opengl-normal-maps
16
+ - `pageUrl("pricing")` → https://normalmapai.com/pricing
17
+
18
+ Source: https://github.com/wangneo276-lgtm/normalmapai-url-tools
19
+
20
+ License: MIT.
@@ -0,0 +1,67 @@
1
+ module NormalMapAiUrlTools
2
+ ORIGIN = 'https://normalmapai.com'.freeze
3
+ DESCRIPTION = 'Free normal map generator by NormalMapAI. Convert any photo into a normal map with live 3D preview — plus height, roughness, AO and more. Private in-browser; export for Unity, Unreal, Godot and Blender.'.freeze
4
+ PATHS = ['/', '/app', '/pricing', '/guides', '/about', '/contact', '/privacy', '/terms', '/ai-texture-generator', '/ai-3d-texture', '/ai-3d-model-generator', '/seamless-texture', '/metallic-map-generator', '/curvature-map-generator', '/orm-map-generator', '/glossiness-map-generator', '/albedo-map-generator', '/tileable-texture-generator', '/normal-map-inverter', '/height-to-normal-map', '/normal-to-height-map', '/seamless-texture-checker', '/3d-print-height-map', '/power-of-two-texture-resizer', '/bump-map-generator', '/ao-map-generator', '/roughness-map-generator', '/height-map-generator', '/displacement-map-generator', '/specular-map-generator', '/texture-maker', '/pbr-texture-generator', '/transparent-png', '/image-to-normal-map', '/guides/how-to-use-normal-map-generator', '/guides/how-to-make-seamless-textures', '/guides/import-pbr-maps-unity-unreal-blender', '/guides/pbr-maps-explained', '/guides/height-vs-displacement-maps', '/guides/directx-vs-opengl-normal-maps'].freeze
5
+ MAPS = {"normal" => "/image-to-normal-map", "height" => "/height-map-generator", "roughness" => "/roughness-map-generator", "ao" => "/ao-map-generator", "bump" => "/bump-map-generator", "displacement" => "/displacement-map-generator", "specular" => "/specular-map-generator", "metallic" => "/metallic-map-generator", "curvature" => "/curvature-map-generator", "orm" => "/orm-map-generator", "glossiness" => "/glossiness-map-generator", "albedo" => "/albedo-map-generator"}.freeze
6
+ GUIDES = {"how-to-use-normal-map-generator" => "/guides/how-to-use-normal-map-generator", "how-to-make-seamless-textures" => "/guides/how-to-make-seamless-textures", "import-pbr-maps-unity-unreal-blender" => "/guides/import-pbr-maps-unity-unreal-blender", "pbr-maps-explained" => "/guides/pbr-maps-explained", "height-vs-displacement-maps" => "/guides/height-vs-displacement-maps", "directx-vs-opengl-normal-maps" => "/guides/directx-vs-opengl-normal-maps"}.freeze
7
+ PAGES = {"home" => "/", "app" => "/app", "pricing" => "/pricing", "guides" => "/guides", "about" => "/about", "contact" => "/contact", "privacy" => "/privacy", "terms" => "/terms"}.freeze
8
+
9
+ module_function
10
+
11
+ def canonical_url(input)
12
+ raise ArgumentError, 'path required' unless input.is_a?(String)
13
+ raw = input.strip
14
+ raise ArgumentError, 'path required' if raw.empty?
15
+ raise ArgumentError, 'invalid path' if raw.include?('\\') || raw.include?('%')
16
+ raw = raw.split('#', 2)[0]
17
+ raw = raw.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[8..]
22
+ elsif lower.start_with?('http://')
23
+ raw[7..]
24
+ else
25
+ raw[2..]
26
+ end
27
+ slash = rest.index('/')
28
+ hostport = slash.nil? ? rest : rest[0...slash]
29
+ path = slash.nil? ? '/' : rest[slash..]
30
+ raise ArgumentError, 'userinfo not allowed' if hostport.include?('@')
31
+ raise ArgumentError, 'port not allowed' if hostport.include?(':')
32
+ raise ArgumentError, 'host not allowed' unless hostport.downcase == 'normalmapai.com'
33
+ elsif raw.start_with?('/')
34
+ path = raw
35
+ else
36
+ path = '/' + raw
37
+ end
38
+ path = path.downcase
39
+ path = path.gsub(%r{//+}, '/')
40
+ path.split('/').each do |seg|
41
+ raise ArgumentError, 'path traversal' if seg == '.' || seg == '..'
42
+ end
43
+ path = path.sub(%r{/+$}, '') if path.length > 1
44
+ path = '/' if path.empty?
45
+ raise ArgumentError, 'unknown path: ' + path unless PATHS.include?(path)
46
+ path == '/' ? ORIGIN + '/' : ORIGIN + path
47
+ end
48
+
49
+ def home_url
50
+ canonical_url('/')
51
+ end
52
+
53
+ def page_url(name)
54
+ path = PAGES[name] or raise ArgumentError, 'unknown page: ' + name
55
+ canonical_url(path)
56
+ end
57
+
58
+ def map_url(kind)
59
+ path = MAPS[kind] or raise ArgumentError, 'unknown map: ' + kind
60
+ canonical_url(path)
61
+ end
62
+
63
+ def guide_url(slug)
64
+ path = GUIDES[slug] or raise ArgumentError, 'unknown guide: ' + slug
65
+ canonical_url(path)
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: normalmapai-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 normal map generator by NormalMapAI. Convert any photo into a normal
13
+ map with live 3D preview — plus height, roughness, AO and more. Private in-browser;
14
+ export for Unity, Unreal, Godot and Blender.
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - ruby/lib/normalmapai_url_tools.rb
22
+ homepage: https://normalmapai.com/
23
+ licenses:
24
+ - MIT
25
+ metadata:
26
+ homepage_uri: https://normalmapai.com/
27
+ source_code_uri: https://github.com/wangneo276-lgtm/normalmapai-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 normal map generator by NormalMapAI. Convert any photo into a normal
45
+ map with live 3D preview — plus height, roughness, AO and more. Private in-browser;
46
+ export for Unity, Unreal, Godot and Blender.
47
+ test_files: []